Computing.Net > Forums > Disk Operating System > Dos move command

Dos move command

Reply to Message Icon

Original Message
Name: Niall
Date: June 18, 2002 at 08:11:12 Pacific
Subject: Dos move command
Comment:

I am looking for a dos command to move files from their present folder to the folder above. There are hundreds of such folders so the command will have to seek out the files and move them up one level leaving the original folder empty but intact. Ideally this will run in a batch processing manner.

I have looked at move, xcopy etc and don't think they will work.

Thanks in advance for your help

Regards
Niall


Report Offensive Message For Removal


Response Number 1
Name: tom
Date: June 18, 2002 at 09:29:30 Pacific
Subject: Dos move command
Reply: (edit)

Depends on how you want to do it.
If you are in the directory of the files
to be moved, and you want to move all the
files up one level, then:

move *.* ..
(that's two dots for next level up)
If you wanted to move from c:\dos\etc\test
and you weren't in that directory, then:

move c:\dos\etc\test\*.* c:\dos\etc

tom


Report Offensive Follow Up For Removal

Response Number 2
Name: Niall
Date: June 18, 2002 at 09:46:29 Pacific
Subject: Dos move command
Reply: (edit)

Hi Tom

the files in question are in the following structure
h:\images\01256\b2june1909\
I am dealing with tiff files and they are located in the last subfolder. The date folder and second last subfolder (I will call this the batch folder)names change each time. I have a couple of thousand of such folders.
I want to go to h:\images and run a command that will move all the tiff into the batch folder (i.e. the folder above where they are now) and retain the original folder. As I am dealing with a large number of folders I was hoping to kick it off and let it run and not have to intervene for each batch to change the path.

Regards
Niall


Report Offensive Follow Up For Removal

Response Number 3
Name: tom
Date: June 18, 2002 at 10:46:05 Pacific
Subject: Dos move command
Reply: (edit)

Ah. IC.
Well.. soon as "secret doom" wakes up out
there, he'll have a solution!

Tom


Report Offensive Follow Up For Removal

Response Number 4
Name: Secret_Doom
Date: June 18, 2002 at 12:48:53 Pacific
Subject: Dos move command
Reply: (edit)

Hi guys. Yes, I've got a solution.

The following batch script is a solution for Windows 9x. It must be run from your H:\IMAGES.

===== BATCH SCRIPT BEGIN =====
:: Leonardo Pignataro (secret_doom@hotmail.com)
:: Developed and tested under Win9x
:: Script de-activated.
@echo off
if "%1"=="GoTo:" %1%2

%COMSPEC% /e:2048 /c %0 GoTo: start
goto eof
:start

:: Temporary files table - preserve extentions
SET F1=%TEMP%.\TEMP01.COM
SET T0=%TEMP%.\TEMP02.BAT
SET T1=%TEMP%.\TEMP03.BAT
SET T2=%TEMP%.\TEMP04.BAT

:: Assembler by William Allen
ECHO.e100 86 6 3A 1 86 6 3B 1 BA 3A 1 B9 1 0 BB 0> %T0%
ECHO.e110 0 B4 3F CD 21 9 C0 74 1C BA 3A 1 B9 1 0 80>> %T0%
ECHO.e120 3E 3B 1 A 75 6 BA 37 1 B9 4 0 BB 1 0 B4>> %T0%
ECHO.e130 40 CD 21 EB CB CD 20 25 50 25 A 0>> %T0%
FOR %%C IN (n%F1% rcx 3c w q) DO ECHO.%%C>> %T0%
DEBUG < %T0% > nul

SET DIRCMD=
SET P=call %0 GoTo: LEVEL2;
dir/ad/b > %T0%
%F1% < %T0% > %T1%
call %T1%

for %%? in (%F1% %T0% %T1% %T2%) do if exist %%? del %%?
goto eof

:LEVEL2
cd %3
SET P=call ..\%0 GoTo: LEVEL3;
dir/ad/b > %T0%
%F1% < %T0% > %T2%
call %T2%
cd..
SET P=call %0 GoTo: LEVEL2;
goto eof

:LEVEL3
:: To activate script,
:: remove 'echo.{demo}' from next line
echo.{demo}MOVE %3\*.* .

:eof
===== BATCH SCRIPT END =====

Watch out for line wrapping. This script is de-activated. Run it and check the output. That's what is going to be executed if the script is activated. If it looks right, then activate the script (read commented lines).

If you're on NT, this script should do it:

@echo off
FOR /D %%a in (*.*) do (
FOR /D %%b in (%%a\*.*) do (
MOVE %%b\*.* %%a
) )

So, this is what you were looking for?

-- Secret_Doom - Leonardo Pignataro --

secret_doom@hotmail.com
www.batch.hpg.com.br


Report Offensive Follow Up For Removal

Response Number 5
Name: Niall
Date: June 19, 2002 at 10:04:50 Pacific
Subject: Dos move command
Reply: (edit)

Hi Secret_Doom

Thanks for your reply

I am getting a error message about the syntax. I am using Windows Nt.

Here is the syntax I have used

@echo off
FOR /D %%a in (*.*) do (
FOR /D %%b in (%%a\*.*) do (
MOVE %%b\*.* %%a
) )

If you have any amendments for this I would be grateful.

the file structure is as follows

H:\images\year_1999\012234\b5sept1999\*.tiff

All the images are in the last subfolder and I wish to move them to the second last 012234 folder and leave the last folder intact and empty.

There are thousands of these folders and the last three subfolders change (last frequently as you get towards the root.

Thanks in advance

Niall


Report Offensive Follow Up For Removal


Response Number 6
Name: Secret_Doom
Date: June 19, 2002 at 10:29:43 Pacific
Subject: Dos move command
Reply: (edit)

You hadn't menitioned anything about that year_1999 folder (one more folder level). You said it was on H:\images\012234\b5sept1999\*.tiff, didn't you? That new directory tree have one more level -- that's why the script ain't working.

This should do it:

@echo off
FOR /D %%a in (*.*) do (
FOR /D %%b in (%%a\*.*) do (
FOR /D %%c in (%%b\*.*) do (
MOVE %%c\*.tiff %%b
) ) )

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


Report Offensive Follow Up For Removal

Response Number 7
Name: Secret_Doom
Date: June 19, 2002 at 11:19:36 Pacific
Subject: Dos move command
Reply: (edit)

Oh, by the way, that script was only tested on Win95Cmd.exe, which is some sort of W2000 CMD.EXE emulator.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


Report Offensive Follow Up For Removal

Response Number 8
Name: Niall
Date: June 20, 2002 at 09:14:15 Pacific
Subject: Dos move command
Reply: (edit)

Hi secret_doom

I copied that script into a batch file and ran it from the appropriate folder but got the error message saying that the syntax was incorrect.

I'm on an NT4 system.

Any ideas

Niall


Report Offensive Follow Up For Removal

Response Number 9
Name: Secret_Doom
Date: June 20, 2002 at 11:00:57 Pacific
Subject: Dos move command
Reply: (edit)

As I said, this was only "virtualy" tested on Windows 2000, not on NT4. The FOR command might be different between both. Or maybe the MOVE command is the one giving the sintax error.

Try this:

@echo off
FOR /D %%a in (*.*) do (
FOR /D %%b in (%%a\*.*) do (
FOR /D %%c in (%%b\*.*) do (
echo.{demo}MOVE %%c\*.tiff %%b
) ) )

If it still gives sintax error, then the error is on the FOR command. If it doesn't return errors, then the error is on the MOVE command.

I can't help too much, since I don't have much experience on NT. Try asking at news:alt.msdos.batch.nt

-- Secret_Doom - Leonardo Pignataro --

secret_doom@hotmail.com
www.batch.hpg.com.br


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Dos move command  

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge