batch input to organize

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
blackpete
Posts: 36
Joined: 31 Jul 2012 16:14

Re: batch input to organize

#46 Post by blackpete » 03 Aug 2012 11:04

Hi foxidrive, with this command "cd /d "%drive%\ORGANIZED"
nope! it didn´t change to the organized folder. Maybe I didn´t explain myself.

When the program run the last routine,

if not exist %drive%\ORGANIZED\INTERNET-FILES md %drive%\ORGANIZED\INTERNET-FILES
for %%x in (htm html) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZED\INTERNET-FILES

I want it to open the folder called ORGANIZED and I will take off this comment at the end:

ECHO ..................................................................................................
ECHO REMEMBER, LOOK FOR FOLDER "ORGANIZED" IN THE DRIVE YOU SELECTED
ECHO ..................................................................................................

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch input to organize

#47 Post by foxidrive » 03 Aug 2012 11:12

Try this. Tell me what it prints to the console.

Code: Select all

cd /d "%drive%\ORGANIZED"

echo %cd%
pause

blackpete
Posts: 36
Joined: 31 Jul 2012 16:14

Re: batch input to organize

#48 Post by blackpete » 03 Aug 2012 11:52

It printed:
C:\ORGANIZED
press any key to continue...

Does not change to that directory!

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: batch input to organize

#49 Post by Squashman » 03 Aug 2012 12:02

blackpete wrote:It printed:
C:\ORGANIZED
press any key to continue...

Does not change to that directory!

How can you say that. It just echoed the current working directory to your screen. Proof is in the pudding.

blackpete
Posts: 36
Joined: 31 Jul 2012 16:14

Re: batch input to organize

#50 Post by blackpete » 03 Aug 2012 12:24

Yes Squashman, it did echoed, but only to the CMD screen. but it didn´t actually open a windows showing the contents of the ORGANIZED folder.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch input to organize

#51 Post by foxidrive » 03 Aug 2012 12:40

Ahh, *thats* what you want. :)

Try this:

Code: Select all

start "" "%comspec%" /k dir "%drive%\organized"



Mind you, with the cd /d syntax it will then close your batch file and leave you in the organized folder.


so this will work as the last lines too:

Code: Select all

cd /d "%drive%\ORGANIZED"
dir



But what I think you want is this: a windows folder view.

Code: Select all

explorer  "%drive%\ORGANIZED"

blackpete
Posts: 36
Joined: 31 Jul 2012 16:14

Re: batch input to organize

#52 Post by blackpete » 03 Aug 2012 13:26

Yes, that is what I was looking for.

See the other commands would show a directory inside a CMD screen:

start "" "%comspec%" /k dir "%drive%\organized"
cd /d "%drive%\ORGANIZED"
dir

But now, with this :
explorer "%drive%\ORGANIZED"

it shows the finish job.

Good foxdrive! moving along......

blackpete
Posts: 36
Joined: 31 Jul 2012 16:14

Re: batch input to organize

#53 Post by blackpete » 03 Aug 2012 13:36

So this is the English version:

Code:
@echo off
cls
:MENU
ECHO.
ECHO .....................................................................
ECHO THIS PROGRAM WILL ORGANIZE YOUR SCATTERED FILES INTO SEPARATE FOLDERS
ECHO .....................................................................
ECHO.
ECHO C: - 1
ECHO D: - 2
ECHO E: - 3
ECHO F: - 4
ECHO G: - 5
ECHO H: - 6
ECHO I: - 7
ECHO EXIT - 8
ECHO.

set drive=
set /p drive= WHICH DRIVE DO YOU WANT TO ORGANIZE FIRST?
ECHO ---------------------------------------
if "%drive%"=="1" (set "drive=C:"
)else if "%drive%"=="2" (set "drive=D:"
)else if "%drive%"=="3" (set "drive=E:"
)else if "%drive%"=="4" (set "drive=F:"
)else if "%drive%"=="5" (set "drive=G:"
)else if "%drive%"=="6" (set "drive=H:"
)else if "%drive%"=="7" (set "drive=I:"
)else if "%drive%"=="8" (goto :eof
) else goto :menu


if not exist %drive%\ORGANIZED\DOCUMENTS md %drive%\ORGANIZED\DOCUMENTS
for %%x in (doc txt docx pdf rtf vsd wpd wri) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZED\DOCUMENTS
if not exist %drive%\ORGANIZED\PHOTOS md %drive%\ORGANIZED\PHOTOS
for %%x in (bmp gif jpg jpeg png tiff psd psp wmf) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZED\PHOTOS
if not exist %drive%\ORGANIZED\MUSIC md %drive%\ORGANIZED\MUSIC
for %%x in (mp3 wav wma mid m4a au ape) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZED\MUSIC
if not exist %drive%\ORGANIZED\POWERPOINT md %drive%\ORGANIZED\POWERPOINT
for %%x in (ppt pptx) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZED\POWERPOINT
if not exist %drive%\ORGANIZED\EXCEL md %drive%\ORGANIZED\EXCEL
for %%x in (xls xlsx) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZED\EXCEL
if not exist %drive%\ORGANIZED\VIDEO md %drive%\ORGANIZED\VIDEO
for %%x in (wmv avi mov flv m4v rmvb mpeg) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZED\VIDEO
if not exist %drive%\ORGANIZED\COMPRESS-FILES md %drive%\ORGANIZED\COMPRESS-FILES
for %%x in (zip rar ace 7z gz) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZED\COMPRESS-FILES
if not exist %drive%\ORGANIZED\INTERNET-FILES md %drive%\ORGANIZED\INTERNET-FILES
for %%x in (htm html) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZED\INTERNET-FILES
ECHO.
ECHO ----------------------------------------------------------------
ECHO JOB IS DONE---PRESS ANY KEY AND CHECK
ECHO ----------------------------------------------------------------
pause>nul
explorer "%drive%\ORGANIZED"
Last edited by blackpete on 03 Aug 2012 20:26, edited 1 time in total.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: batch input to organize

#54 Post by Squashman » 03 Aug 2012 13:40

Code: Select all

start .

That's a period after the start command.

blackpete
Posts: 36
Joined: 31 Jul 2012 16:14

Re: batch input to organize

#55 Post by blackpete » 03 Aug 2012 16:55

Squashman, That's a period after the start command.
What start command?

blackpete
Posts: 36
Joined: 31 Jul 2012 16:14

Re: batch input to organize

#56 Post by blackpete » 03 Aug 2012 16:56

This is the Spanish version:

edited by Squashman to put CODE tags around the code

Code: Select all

@echo off
cls
:MENU
ECHO.
ECHO .....................................................................
ECHO      ESTE PROGRAMA ORGANIZA SUS ARCHIVOS QUE ESTAN DESORDENADOS
ECHO .....................................................................
ECHO.
ECHO          C: - 1
ECHO          D: - 2
ECHO          E: - 3
ECHO          F: - 4
ECHO          G: - 5
ECHO          H: - 6
ECHO          I: - 7
ECHO            SALIR - 8
ECHO.

set drive=
set /p drive= CUAL DISCO QUIERE ORGANIZAR PRIMERO?
ECHO          ---------------------------------------
if "%drive%"=="1" (set "drive=C:"
)else if "%drive%"=="2" (set "drive=D:"
)else if "%drive%"=="3" (set "drive=E:"
)else if "%drive%"=="4" (set "drive=F:"
)else if "%drive%"=="5" (set "drive=G:"
)else if "%drive%"=="6" (set "drive=H:"
)else if "%drive%"=="7" (set "drive=I:"
)else if "%drive%"=="8" (goto :eof
) else goto :menu


if not exist %drive%\ORGANIZADO\DOCUMENTOS md %drive%\ORGANIZADO\DOCUMENTOS
for %%x in (doc txt docx pdf rtf vsd wpd wri) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZADO\DOCUMENTOS
if not exist %drive%\ORGANIZED\PHOTOS md %drive%\ORGANIZADO\FOTOS
for %%x in (bmp gif jpg jpeg png tiff psd psp wmf) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZADO\FOTOS
if not exist %drive%\ORGANIZADO\MUSICA md %drive%\ORGANIZADO\MUSICA
for %%x in (mp3 wav wma mid m4a au ape) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZADO\MUSICA
if not exist %drive%\ORGANIZADO\POWERPOINT md %drive%\ORGANIZADO\POWERPOINT
for %%x in (ppt pptx) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZADO\POWERPOINT
if not exist %drive%\ORGANIZADO\EXCEL md %drive%\ORGANIZADO\EXCEL
for %%x in (xls xlsx) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZADO\EXCEL
if not exist %drive%\ORGANIZADO\VIDEO md %drive%\ORGANIZADO\VIDEO
for %%x in (wmv avi mov flv m4v rmvb mpeg) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZADO\VIDEO
if not exist %drive%\ORGANIZADO\ARCHIVOS-COMPRIMIDOS md %drive%\ORGANIZADO\ARCHIVOS-COMPRIMIDOS
for %%x in (zip rar ace 7z gz) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZADO\ARCHIVOS-COMPRIMIDOS
if not exist %drive%\ORGANIZADO\ARCHIVOS-INTERNET md %drive%\ORGANIZADO\ARCHIVOS-INTERNET
for %%x in (htm html) do move >nul 2>nul /-y %drive%\*.%%x %drive%\ORGANIZADO\ARCHIVOS-INTERNET
ECHO.
ECHO ----------------------------------------------------------------
ECHO           TRABAJO TERMINADO---PRESIONE UNA TECLA PARA REVISAR
ECHO ----------------------------------------------------------------
pause>nul
explorer  "%drive%\ORGANIZADO"

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: batch input to organize

#57 Post by Squashman » 03 Aug 2012 17:06

blackpete wrote:Squashman, That's a period after the start command.
What start command?

The START command like Foxidrive was showing you in his previous code. There is a command called START.
When you see someone put something in CODE tags on the forums that means it is code you can run in a batch file.

In a batch file or even at the command prompt type:

Code: Select all

start .

See what it does!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch input to organize

#58 Post by foxidrive » 03 Aug 2012 17:32

blackpete, your code will 'organise' the directory that the batch file is launched in, not just the root folder.

That has the potential for unintended consequences, unless the user is made aware of it.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch input to organize

#59 Post by foxidrive » 03 Aug 2012 17:34

Squashman wrote:In a batch file or even at the command prompt type:

Code: Select all

start .

See what it does!


That could be useful. I hadn't thought to try that before.

blackpete
Posts: 36
Joined: 31 Jul 2012 16:14

Re: batch input to organize

#60 Post by blackpete » 03 Aug 2012 20:56

foxidrive, if I typed (start.) with a dot, at the command prompt, it gives me a windows folder view of where I am.
So if I am at C:\ it will show all the folder in there.
Now, if I typed only (start) without the dot, will open another CMD windows.

To clarify something foxidrive, I don´t know if your quote is a question or a statement.
"blackpete, your code will 'organise' the directory that the batch file is launched in, not just the root folder.
That has the potential for unintended consequences, unless the user is made aware of it."

but, I can tell you that I have being testing the batch in this manner:

Batch file located in the desktop, double click, choose the drive, per example C: and it creates in C: a folder called organized with all the sub-folders, and moves all the scattered files in the desktop to the different sub-folders.
I have also tried it in my partition D:, always called from the desktop in C:
And one last thing, I just copied the batch to D: and launch it from there to organize C: and did the job in the same way.

Do you need more proof?

Post Reply