homepage Welcome to WebmasterWorld Guest from 54.242.126.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft Windows OS (XP/NT/Vista/Windows 7/8/9/10)
Forum Library, Charter, Moderators: bill

Microsoft Windows OS (XP/NT/Vista/Windows 7/8/9/10) Forum

    
MS DOS move
andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3752772 posted 3:59 pm on Sep 26, 2008 (gmt 0)

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

WebmasterWorld Administrator bill us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3752772 posted 12:05 am on Sep 27, 2008 (gmt 0)

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

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3752772 posted 1:05 pm on Sep 29, 2008 (gmt 0)

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

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3752772 posted 1:06 pm on Sep 29, 2008 (gmt 0)

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

coopster

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



 
Msg#: 3752772 posted 1:17 pm on Sep 29, 2008 (gmt 0)

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

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3752772 posted 2:38 pm on Sep 29, 2008 (gmt 0)

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

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



 
Msg#: 3752772 posted 4:02 pm on Sep 29, 2008 (gmt 0)

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

WebmasterWorld Administrator bill us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3752772 posted 2:04 am on Sep 30, 2008 (gmt 0)

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

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



 
Msg#: 3752772 posted 2:42 am on Sep 30, 2008 (gmt 0)

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

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3752772 posted 2:53 am on Sep 30, 2008 (gmt 0)

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

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3752772 posted 11:58 am on Sep 30, 2008 (gmt 0)

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,

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft Windows OS (XP/NT/Vista/Windows 7/8/9/10)
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved