error404 Posted May 13, 2015 Posted May 13, 2015 Hi Guys Working on a script whereby Staff Scans in Students Exams Certificates via Photocopier and it then places a copy to a location the script below does the following 1) Scans to C:\users\location as filename.pdf (The Staff member will manually enter STudent number at the photocopier and it will save the file name as that) 2) Script then creates folder based on filename so here it will create a folder called /filename 3) Moves the PDF into that folder it all works fine however i am trying to modify it so it does not overwrite so if for example staff member makes a typo of student1 and student1 already exists we dont want to override it any suggestions script is as below you can test it @echo off pushd C:\Users\location for %%F in (*.pdf) do ( 2>nul md "%%~nF" >nul move /y "%%~nF*.*" "%%~nF" ) popd
error404 Posted May 14, 2015 Author Posted May 14, 2015 Here is the solution incase anyone needs it @echo off pushd C:\Users\location for %%F in (*.pdf) do ( 2>nul md "%%~nF" echo n|move /-y "%%~nF*.*" "%%~nF" >nul 2>nul || ( 2>nul md "%%~nF_2" move "%%~nF_2*.*" "%%~nF_2" >nul 2>nul ) ) popd
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now