Sign in with
Sign up | Sign in
Your question
Solved

Need Help with a Batch File

Last response: in Windows 7
Share
June 10, 2011 6:52:16 PM

Hi guys

I need to orginize a folder full of scanned document for like 2 years now, i need help writing a batch file to sort the file in to folders according to the Year and month they are created.

i Googled around found some tools, but there is no way to automate this every month via the task scheduler.

Please help me guys Thanks a Load in advance

More about : batch file

June 10, 2011 11:29:44 PM

So you want it to check the year and month of all the files in a directory, create new directories with a name that is month and year, then put the files in the appropriate directory. Does that sound right?

What file extension are they? Will there be files of any other extension in the directory?
June 13, 2011 1:45:22 AM

If you want help, please answer my questions. I have something done in VB.Net that might work for you.
Related resources
Can't find your answer ? Ask !
June 15, 2011 6:27:54 PM


It would be interesting to try out with a CMD batch file. Can you also give some examples of the file names and how you would like the folders to look like.
June 15, 2011 8:04:38 PM

What the guy wanted to do with a batch file was a bit complicated for me, however, it was really easy to do with VB. I'd be curious to see what you come up with using a batch.

In my VB program an example of folder that I created would be "2011 Jun", then I just dump any file that was created that in that month and year into it. I had a bunch of random .jpg's handy so I toyed around with those.
June 15, 2011 8:20:04 PM

dmroeder said:
What the guy wanted to do with a batch file was a bit complicated for me, however, it was really easy to do with VB. I'd be curious to see what you come up with using a batch.


I will throw something together using CMD and then we can compare it. :) 


Best solution

a c 209 $ Windows 7
June 15, 2011 10:11:02 PM
Share

This sort of thing is really easy to do in PowerShell if you know how to use it:

$FromFolder = "D:\Photos"
$ToFolder = "D:\SortedPhotos"

get-childitem $FromFolder -recurse -include *.jpg |
foreach-object {
$FolderName = "$ToFolder\{0}-{1:00}" -f $_.LastWriteTime.Year, $_.LastWriteTime.Month
if ( -not (test-path $FolderName) ) { mkdir $FolderName | out-null }
$_.MoveTo( $FolderName + "\" + $_.Name )
}
June 18, 2011 7:42:31 AM

Dman THG dosent send a notification when there is a reply totaly missed to check the thread..

i managed to find a VB script and modify it..Thank you so much for your input guys...so sorry i didnt get to reply


June 25, 2011 7:09:49 PM

Best answer selected by malindar.
!