I am using T-SQL
I have a few excel files located here: C:\\MyFiles\\
I want to remove all the apostrophes in the file names in that directory.<
First you need to enable xp_cmdshell
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO
Then you can use sp_cmdshell to retrieve the files names from the directory
Declare @Directory TABLE (Files Varchar(MAX))
Declare @File TABLE (Name varchar(MAX))
INSERT INTO @Directory
EXEC XP_CMDSHELL 'DIR "D:"'
Insert into @File
Select reverse(LEFT(reverse(Files),charindex(' ' ,reverse(Files)))) from @Directory
Select * from @FILE
Now you get the file names in the table variable @FILE and use function like replace or your own custom function to replace apostrophes with the exact filename