I’m trying to write a .bat script to rename every file in a folder by removing all characters in all the file names up to the first space. I.e.:
ABC defghij -> defghij
And I need to automate this for all files in the folder. Is there a way to do this?
This is what I tried:
For %y in (directory) do (for /f “tokens=1,*” %%A in %y do ren %y” “%%B”)
Always verify against a test directory before applying to real data.
Notes
%yis correct from the command prompt, butmetavariableslike%%yneed a double%in a batch file.The required REN commands are merely
ECHOed for testing purposes. After you've verified that the commands are correct, changeECHO RENtoRENto actually rename the files.Fairly simple process - process a directory list matching the filemask of filenames only, tokenise as attempted, test whether rename is possible, report if it is not & rename if it is.