Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Batch Programming Help

    Ok so here is the scenario. I have many pdf files where each file corresponds to 1 person. I need to move these files into a unique folder for each person. This Folder will be titled "Last Name (Last 4 Digits of SSN)". So here is how the folder looks now...

    Rivera.pdf
    Jacobs.pdf
    Knoblauch.pdf

    I need the .bat file to then put those files into their own folder
    Rivera 1234
    Jacobs 2345
    Knoblauch 3456

    I know somewhere I'm going to need an sql statement to place the file within the correct folder. My code now creates folders with the same name as the pdf file.

    Code:
    @echo off
    
    REM Loop through every file in this folder
    REM Excluding this batch file!
    
    for /f "delims=" %%A in ( ' dir /b /a-d ^| find /v "%~nx0" ' ) do (
    
    	REM If a folder with the same base name
    	REM does not exist, create it
    	if not exist "%%~nA" md "%%~nA"
    
    	REM Move the file into the folder
    	REM and show message to user
    	echo Moving file: %%A to folder: %%~nA 
    	move "%%A" "%%~nA"
    	)
    
    REM Complete
    echo Done
    echo.
    I found this code online and don't know how to completely decipher it so any help with that is also appreciated.

  • #2
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the SSN's are in a spreadsheet


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •