Welcome to WebmasterWorld Guest from 107.20.34.173

Forum Moderators: bill

Message Too Old, No Replies

MS DOS move

     

andrewsmd

3:59 pm on Sep 26, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I have a batch file that calls an FTP script and downloads files to a temporary folder. At the end of my batc file after the FTP script has ran, I have a move command i.e. move *.* "C:\some folder\" Now sometimes files land in this folder with the same name. Is there anyway to run that move command, but not move the file if that filename is already in the folder. What I mean is say I have three files in the download temp
tempFile1.txt
tempFile2.txt
tempFile3.txt
Now I'm moving them to "some folder" with the command move *.* "C:\some folder\" let's say that tempFile1.txt already exists in "some folder" is there anyway for me to skip that move but still move tempFile2.txt and tempFile3.txt? Thanks,

bill

12:05 am on Sep 27, 2008 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



The move [technet.microsoft.com] command doesn't have many options for you to play with.

move [{/yŽ/-y}] [Source] [target]

You could use the /-y switch to force the script to prompt you when overwriting existing files.

It might be easier to use something like xCopy [technet.microsoft.com] to get the files to the new location and then to delete the files from the old location.

andrewsmd

1:05 pm on Sep 29, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I know how to use xCopy, but what is the switch to not overwrite file within that command. Most of the time when I am copying files I use something like
xcopy "sourcePath" "destinationPath" /e /i /c /s /k /y

andrewsmd

1:06 pm on Sep 29, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Also, the y prompt won't work because I want this script to run automatically and not have to watch it.

coopster

1:17 pm on Sep 29, 2008 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Sometimes you end up jumping through hoops trying to use an antiquated tool to accomplish the task at hand. I still use .bat file scripts on occasion myself, but when it comes to a bit more *advanced* system work, tools such as perl/php make the task a piece of cake. Have you considered executing a scripted process from your .bat file?

andrewsmd

2:38 pm on Sep 29, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



No, I could whip this out with php in about 10 minutes. How would I execute that from the dos prompt then. This bat file is running on a computer we will call machine1, but my php server is on a completely different machine. I have the folder where all of my php files are shared with the administrator so I can get to the folder, but how to I call a php script from the dos shell and also, how does output work when you do something like that. Thanks,

coopster

4:02 pm on Sep 29, 2008 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



but how to I call a php script from the dos shell and also, how does output work when you do something like that.

Using PHP from the command line [php.net]

bill

2:04 am on Sep 30, 2008 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I know how to use xCopy, but what is the switch to not overwrite file within that command.

It actually gets a bit more complicated, but you can use the /l switch to list the files to be copied and then run a for...next loop to only copy the file names that don't exist.

A better option than xCopy might be Robocopy [technet.microsoft.com], but it may not be available natively on your platform.

tangor

2:42 am on Sep 30, 2008 (gmt 0)

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



use IF %f NOT EXIST in the command line (If I recall correctly... been a long time since DOS.

andrewsmd

2:53 am on Sep 30, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I have used IF NOT EXIST before but never with the %f what does that do. I'm not gonna lie I really don't know that much about MS DOS I'm a web programmer

andrewsmd

11:58 am on Sep 30, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



While we are in this forum. Does anyone know how to echo the date modified on a file with dos in a readable format. Like YYYYMMDDHHIISS? Thanks,
 

Featured Threads

Hot Threads This Week

Hot Threads This Month