Digg this topic Add to my del.icio.us Submit to SlashDot  
Reply to this topicStart new topic
> [HELP] CMD code, check folder
Xtremee
post Oct 7 2007, 04:31 AM
Post #1


Member
**

Group: Members
Posts: 15
Joined: 8-August 06
Member No.: 136



Hi all,
wanna to know how i check if a certain folder had been copied or not so that the .cmd can take a certain action i try
CODE
IF "%ERRORLEVEL%"=="1" (GOTO :error2)else goto :done
but it work only with files

Any idea !! (IMG:http://www.boot-land.net/forums/style_emoticons/default/yammer.gif)
Go to the top of the page
 
+Quote Post
Alexei
post Oct 7 2007, 05:49 AM
Post #2


Advanced Member
***

Group: .script developer
Posts: 533
Joined: 30-August 06
Member No.: 283



QUOTE (Xtremee @ Oct 6 2007, 09:31 PM) *
Hi all,
wanna to know how i check if a certain folder had been copied or not so that the .cmd can take a certain action i try
CODE
IF "%ERRORLEVEL%"=="1" (GOTO :error2)else goto :done
but it work only with files

Any idea !! (IMG:http://www.boot-land.net/forums/style_emoticons/default/yammer.gif)
One line of code you presented is not enough to answer your question (IMG:http://www.boot-land.net/forums/style_emoticons/default/sad.gif)
Please provide more code and explain your goal, like
I am trying to ...
To do that I ...
I want to check if a ... folder had been copied because ...
To do that I check
CODE
IF "%ERRORLEVEL%"=="1"
But it doesn't work.
Go to the top of the page
 
+Quote Post
jaclaz
post Oct 7 2007, 09:24 AM
Post #3


Finder
***

Group: Advanced user
Posts: 1,165
Joined: 14-July 06
Member No.: 2


Italy


Cannot you check for the existence of the folder?
i.e.
CODE
Set Drive=C:
Set Folder=Somefolder
MD %Drive%\%folder%
IF NOT EXIST %drive%\%folder%\nul.ext (GOTO :Error2) ELSE (GOTO :done)


jaclaz
Go to the top of the page
 
+Quote Post
cquirke
post Oct 7 2007, 10:22 AM
Post #4


Newbie
*

Group: Members
Posts: 4
Joined: 23-August 07
Member No.: 10,225


South Africa


QUOTE (Xtremee @ Oct 7 2007, 06:31 AM) *
Hi all,
wanna to know how i check if a certain folder had been copied or not so that the .cmd can take a certain action i try
CODE
IF "%ERRORLEVEL%"=="1" (GOTO :error2)else goto :done
but it work only with files


If the folder has known contents that you copied there (e.g. when packing an app out from CDR to RAM disk or %Temp% so it can write to itself) then what I'd do, is:
- copy the files in order smallest to largest
- check for existance of last (largest)
- clean up and error if not found

So the test would be...

If Not Exist %SomePath%\%BigFile% GoTo CleanUp

...etc.

If however you want to test for an empty dir, then test for NUL within that dir, e.g...

If Not Exist %SomePath%\NUL GoTo DirNotFound

...or you could force a marker file and test for that, e.g...

Echo I Live... Again! > %SomePath%\TestFile.txt
If Not Exist %SomePath%\TestFile.txt GoTo NotFound
Del %SomePath%\TestFile.txt
If Exist %SomePath%\TestFile.txt GoTo WTF!

...etc. but the first approach is more robust, for the common case of insufficient space for the largest files while enough space for the test file you create and test for.
Go to the top of the page
 
+Quote Post
jaclaz
post Oct 7 2007, 11:07 AM
Post #5


Finder
***

Group: Advanced user
Posts: 1,165
Joined: 14-July 06
Member No.: 2


Italy


As a precaution always check for nul.ext instead of nul:
http://xset.tripod.com/tip5.htm
http://msmvps.com/blogs/martinzugec/archiv...-same-name.aspx

@cquirke
Welcome to the board (IMG:http://www.boot-land.net/forums/style_emoticons/default/smile.gif)


jaclaz
Go to the top of the page
 
+Quote Post
Xtremee
post Oct 7 2007, 01:20 PM
Post #6


Member
**

Group: Members
Posts: 15
Joined: 8-August 06
Member No.: 136



@ jaclaz,
Thanks for help

=======================================================
@ cquirke,
Welcome to the board
I can't understand this
QUOTE
If the folder has known contents that you copied there (e.g. when packing an app out from CDR to RAM disk or %Temp% so it can write to itself) then what I'd do, is:
- copy the files in order smallest to largest
- check for existance of last (largest)
- clean up and error if not found
Go to the top of the page
 
+Quote Post
« Next Oldest · Windows 2K/XP/2003 and Vista · Next Newest »
 

Fast ReplyReply to this topicStart new topic

Members Who Viewed Topic Today ()

 

Display Mode: Standard · Switch to: Linear+ · Switch to: Outline

Track this topic · Email this topic · Print this topic · Subscribe to this forum

RSS Lo-Fi Version Time is now: 27th October 2007 - 01:13 PM

MKPortal ©2003-2006 mkportal.it