I'm a complete newbie when it comes to bat/cmd stuff. I can do the very very basics with a little help from google! & when i mean basic im talking xcopy, robocopy etc.
I am trying to write a code that will extract the 1st 5 characters from the current folder & rename files within a subfolder but also suffix with the current date.
So this is basically what im trying to do.
W:\12345_folder
This is the main folder that I want to extract the 12345 from.
W:\12345_folder\subfolder
This is the location for the files that are to be renamed
Current name of files within subfolder are as follows
file1.txt
file2.txt
file3.txt
After renaming they should be as below
12345 file1 2014-10-02.txt
12345 file2 2014-10-02.txt
12345 file3 2014-10-02.txt
All my efforts have been in vain. I can get the date using this. But it renames the whole filename & does not retain the existing filename.
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "*.txt" %%g%%f-%%e-%%d.txt
And I have also been playing with this:
for %%z in ("%cd%") do (
for %%a in ("%%~dpz%\.") do (
rename "**.txt" "%%~nxa-.txt"))
But again this overwrites the whole filename and does not retain the existing file name.
I must stress once again I am a complete novice so be gentle & your help is greatly appreciated.