Reputation:
I am trying to move zip files from one folder to another one with batch. I want to understand how to complete my piece of code in order to move zip files from one folder to another one renaming files, adding to the name of the file the timestamp.
for /f %%a in ('dir /b \\XXX\XXX\XXX\XXX\XXX\*.zip ^| find /c /v ""') do (
)
EXIT
EDIT
In python I would have written something like this:
Location = '\\\\XXXX\\XXX\\XXX\\XXX\\XXX\\'
checklist2 = glob.glob(Location + '*.zip')
for filename2 in checklist2:
NewName = filename2.replace(Location, '')
NewName = NewName.replace('.ZIP', '')
shutil.move(filename2, Location + 'Archive\\ZIP Archive\\' + NewName + '_' + time.strftime('%Y%m%d%H%M%S') + '.zip')
Upvotes: 1
Views: 326
Reputation: 2135
See if you this helps you:
for %%a in (*) do echo %%~na-%%~ta%%~xa
%%~na
is the name of the file.
%%~ta
is the timestamp of the file.
%%~xa
is the file extension.
Upvotes: 1