-1

Appreciate any help as windows 7 keeps giving following message in spite of directory exists. Sample code with error message are below. Thanks in advance

D:\WebService\Project-Print-Services>move C:\Temp\pdfMerge\build\* C:\Temp\pdfMerge\work\
The filename, directory name, or volume label syntax is incorrect.

I have verified COMPSEC and it is cmd.exe.

Endoro
  • 37,015
  • 8
  • 50
  • 63
Anand
  • 1,845
  • 2
  • 20
  • 25
  • Possible duplicate of [How can I move the contents of one directory tree into another?](http://stackoverflow.com/questions/1118540/how-can-i-move-the-contents-of-one-directory-tree-into-another) – devnull May 06 '13 at 12:24

5 Answers5

3

If you are trying to copy folders (that error message appears when the folder is empty) then see if this helps:

@echo off
for /d %%a in ("C:\Temp\pdfMerge\build\*") do move "%%a" "C:\Temp\pdfMerge\work\"

Note that for running this from the command-line, you should drop one '%' sign,
like this:

for /d %a in ("C:\Temp\pdfMerge\build\*") do move "%a" "C:\Temp\pdfMerge\work\"
Gonen
  • 4,005
  • 1
  • 31
  • 39
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • Thanks for the response, actually source directory build does have many files. – Anand May 06 '13 at 17:26
  • Thanks after adding foxidrive suggested above command, it works though not sure why would other move do not work. Big Thanks Foxidrive. – Anand May 06 '13 at 17:45
1

If you can use PowerShell

Move-Item -path  C:\Temp\pdfMerge\build -destination C:\Temp\pdfMerge\work

Move-Item will not overwrite any existing files in the target folder if you dnt use -force option

Bill
  • 5,263
  • 6
  • 35
  • 50
  • 1
    Why would power shell help? Surely we should work out what's wrong with using `move`, a command that is known to work. – David Heffernan May 06 '13 at 12:25
  • if this step is just of many steps which can be combined in a script....then why not use `powershell`... – Bill May 06 '13 at 12:26
1

do both the folders exist and have files in them?

Try dir C:\Temp\pdfMerge\build\

dir C:\Temp\pdfMerge\work\

Do you want to move the files in side build to work or move the directory build to work? Your current command will do the former.

To move the folder Remove the \* and add /y:

 move /y C:\Temp\pdfMerge\build C:\Temp\pdfMerge\work

From some other dir than build

tgkprog
  • 4,493
  • 4
  • 41
  • 70
  • Thanks for the response. Both source and target does have files. Same move works in windows XP, keep failing only in windows 7 32 bit, not tried in 64 bit though. – Anand May 06 '13 at 17:31
  • if you can use java or VB script can write an app in that (extension will be .vbs can call from command prompt) http://www.computerperformance.co.uk/ezine/ezine36.htm and http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/filesfolders/files/ – tgkprog May 06 '13 at 18:28
  • do you want to move the files in the folder or the complete directory? – tgkprog May 06 '13 at 18:29
  • Actually move all files from build to work, so other process could pick those files for further processing. – Anand May 06 '13 at 18:55
1

Your code works for me, but if C:\Temp\pdfMerge\build is empty, you get an error message. Use the following code to avoid this:

dir C:\Temp\pdfMerge\build /a-d >nul 2>&1 && move C:\Temp\pdfMerge\build\* C:\Temp\pdfMerge\work
Endoro
  • 37,015
  • 8
  • 50
  • 63
  • Actually full code is below which works perfectly well on XP set BASE=D:\WebService\Project-Print-Services set INVOICE_BASE=C:\Temp\pdfMerge set PRINTER_NAME=pdfFactory set LIB=%BASE%\dist\lib set CLASSPATH=.;%LIB%\* move %INVOICE_BASE%\build\* %INVOICE_BASE%\work\ java -Dlog4j.configuration=%BASE%\config\log4j.properties -classpath %CLASSPATH% com.example.print.service.BatchPrint "%INVOICE_BASE%" – Anand May 06 '13 at 17:37
  • OK, but this was **not** your question. – Endoro May 06 '13 at 17:46
  • Actually showed only the portion which was causing the hiccup. – Anand May 06 '13 at 17:49
0

save this in a .vbs file, call it fom command prompt. (see comments)

' arg1 - folder to move
' arg2 - parent folder to move to
' call this with trailing \ in 2nd arg only
'  C:\apps\xamps\x182\htdocs\pages\prog\vba\moveFile.vbs c:\apps\a3 c:\tmp\a\
Set objFSO = CreateObject("Scripting.FileSystemObject")
'MsgBox "a " & WScript.Arguments.Item(0)
'checks and stops if folder does not exist
Set f =  objFSO.GetFolder(WScript.Arguments.Item(0))
Set f =  objFSO.GetFolder(WScript.Arguments.Item(1))
objFSO.MoveFolder  WScript.Arguments.Item(0) , WScript.Arguments.Item(1) 
tgkprog
  • 4,493
  • 4
  • 41
  • 70