After a some hours of "googling" I turn to you with a cry for help;
I´m trying to copy files from a folder structure as follow:
X:\posters\29-apr\SY\D1\001\X.pdf
The files shall be copied to an other location as follow:
Y:\29-apr\ and be named SYD1001.pdf
There are always only one file (pdf) in the folder. The name of the path differs for every file, but it is always \date\XX\YY\###\file.pdf and the destination shall always be \date\XXYY###.pdf (folder should be created if it´s not exists)
Grateful for the assistance
Copy and rename files
Moderator: DosItHelp
Re: Copy and rename files
DXF wrote: (folder should be created if it´s not exists)
For this we need your date format. Post the output of:
Code: Select all
echo %date%
Re: Copy and rename files
This is untested.
It expects all the the dated folders to be directly under x:\posters and that all the PDF files under them are the ones to be copied.
It expects all the the dated folders to be directly under x:\posters and that all the PDF files under them are the ones to be copied.
Code: Select all
@echo off
pushd "x:\posters"
for /f "delims=" %%a in ('dir *.pdf /b /s /a-d') do (
for /f "tokens=3-6 delims=\" %%b in ("%%a") do (
md "y:\%%b" 2>nul
echo copying "%%a"
copy /b "%%a" "y:\%%b\%%c%%d%%e%%~xa" >nul
)
)
popd
Re: Copy and rename files
Thank you very much. You have saved me a lot o work


