Re: Trying to organize 3k+ folders with a script by abuthemagician
abuthemagician
Fri Jul 11 16:01:21 CDT 2008
On Jul 11, 4:56=A0pm, abuthemagic...@gmail.com wrote:
> On Jul 11, 3:03=A0pm, abuthemagic...@gmail.com wrote:
>
>
>
> > On Jul 11, 1:30=A0pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>
> > > <abuthemagic...@gmail.com> wrote in message
>
> > >news:25658a37-3477-4fd7-bfb5-5fa1de9d28a6@25g2000hsx.googlegroups.com.=
..
>
> > > > We have a server that has over 3k =A0folders containing scanned che=
ck
> > > > images, and they need to be organized into folders by year, then
> > > > month, then day. Not every day has images. The naming structure for
> > > > the folders is as follows:
>
> > > > 0011117040010187
>
> > > > 001 (Branch) | 11 (month) | 17 (day) | 04 (year) | 0010187
>
> > > > The folder structure we would like to use looks like this:
>
> > > > 2004
> > > > --11 NOV
> > > > =A0 ---01
> > > > =A0 ---02
>
> > > > etc. We can do this by hand, but with so many images i thought it
> > > > might be easier to use a script. I would figure it out by myself, b=
ut
> > > > I couldn't program to save my life. I almost failed numbers and log=
ic
> > > > in college if that tells you anything. Any help would be appreciate=
d
> > > > though and probably useful to many people in the future :)
>
> > > You could use the following batch file:
> > > 01. @echo off
> > > 02. set Source=3DD:\My Picture Files
> > > 03.
> > > 04. cd /d "%Source%"
> > > 05. for /d %%a in (*.*) do call :Sub %%a
> > > 06. echo All done!
> > > 07. pause
> > > 08. goto :eof
> > > 09.
> > > 10. :Sub
> > > 11. set name=3D%1
> > > 12. set year=3D20%name:~7,2%
> > > 13. set month=3D%name:~3,2%
> > > 14. set day=3D%name:~5,2%
> > > 15. echo md "%cd%\%year%\%month%\%day%"
> > > 16. echo move "%cd%\%1\*.*" "%cd%\%year%\%month%\%day%"
> > > 17. echo rd "%cd%\%1"
> > > 18. pause > nul
> > > 19. echo.
>
> > > Instructions:
> > > 1. Save the above lines as "c:\Windows\MovePics.bat.
> > > 2. Adjust Line #2 to suit your environment.
> > > 3. Remove all line numbers.
> > > 4. Run the batch file in its "pretend" mode. Carefully check the
> > > =A0 =A0 screen output. Press {Enter} each time the batch file pauses.
> > > =A0 =A0 Press Ctrl+C to finish the trial run.
> > > 5. When happy with the result, remove the word "echo" in
> > > =A0 =A0 Lines 15-17.
> > > 6. Run the batch file again. Using Explorer, check the first two
> > > =A0 =A0 or three folders to ensure that you get what you expect. Don'=
t
> > > =A0 =A0 be hasty here - if you let it run without checking things ver=
y
> > > =A0 =A0 carefully then you will get a big disaster in no time at all!=
Press
> > > =A0 =A0 Ctrl+C to finish the single-step run.
> > > 7. When you're totally convinced that the batch file does the right
> > > =A0 =A0 thing, remove Lines 18 and 19 and run it again.
>
> > Awesome i will try this as soon as possible and let you know
>
> Any way to get it to move the folders and not just the images?
>
> For instance:
> =A02004
> =A0--11 NOV
> =A0 ---01
> =A0 ----0011117040010187
>
> > > > =A0 ---02
nevermind. Just needed to add %1 to the end of lines 15 and 16
> > > 15. echo md "%cd%\%year%\%month%\%day%\%1"
> > > 16. echo move "%cd%\%1\*.*" "%cd%\%year%\%month%\%day%\%1"
It works flawlessly