There are two types of FOR command. The plain FOR on files:
Code: Select all
FOR %%F IN (files set) DO command ...
... and the FOR /F on the result of a command:
Code: Select all
FOR /F "options" %%F IN ('command enclosed in apostrophes') DO command ...
..., but your FOR is no one of them!
Code: Select all
FOR /f "delims=" %%F IN ("D:\Sample\*.txt") DO (RENAME "%%F" "Sample_%%F")
If you want to use a FOR /F command, insert a DIR command enclosed in apostrophes this way:
Code: Select all
FOR /f "delims=" %%F IN ('dir /B "D:\Sample\*.txt"') DO (RENAME "%%F" "Sample_%%F")
If you want to use a plain FOR (that is always prefered), remove the /F and the options:
Code: Select all
FOR %%F IN ("D:\Sample\*.txt") DO (RENAME "%%F" "Sample_%%F")
You must also use just the name of the file in the second part of RENAME command as foxidrive suggested, that is: "Sample_%%~nxF .
Antonio