ZippyDo Posted November 17, 2002 Share Posted November 17, 2002 Can someone tell me why this is not working.... Heres the code, in case the .bat doesn't make it ren C:\Program Files\DP Desktop\DPDeskTop.exe DPDeskTop.ex_ Pause Copy x:\DDR\Public\DPDesktop.exe C:\Program Files\DP Desktop\DPDeskTop.exe pause Says "Invalid Syntax" Thanks Link to comment Share on other sites More sharing options...
ilmcuts Posted November 17, 2002 Share Posted November 17, 2002 parameters are separated by a space unless you put quotes around it... ie. in the first line you give ren four parameters instead of two, same in the third line (copy). Haven't tested this but i think it should work: ren "C:\Program Files\DP Desktop\DPDeskTop.exe" DPDeskTop.ex_ Pause Copy x:\DDR\Public\DPDesktop.exe "C:\Program Files\DP Desktop\DPDeskTop.exe" pause Link to comment Share on other sites More sharing options...
ZippyDo Posted November 17, 2002 Author Share Posted November 17, 2002 Thanks, that was it :D Link to comment Share on other sites More sharing options...
ZippyDo Posted November 17, 2002 Author Share Posted November 17, 2002 Another quick question, is there a way to report an error and abort if the file is not initially found in the first line? On Abort, I would like it to say "the program appears to not be found on this system", pause, then exit.... :blink: Would also like to add a brief description line at the beginning that just displays text and asks if you would like to continue with the upgrade.... Thanks Link to comment Share on other sites More sharing options...
hurting101 Posted November 17, 2002 Share Posted November 17, 2002 Yup: if not exist "C:\Program Files\DP Desktop\DPDeskTop.exe" ( echo.The program appears to not be found on this system&pause>nul&goto:eof) Also, you can add @echo off to the beginning of the file to make it stop reading out each line. As for the upgrade thing, you can use echo and pause like this: echo Welcome to my installation echo Press any key to continue with installation pause>nul Link to comment Share on other sites More sharing options...
ilmcuts Posted November 17, 2002 Share Posted November 17, 2002 if exist "c:\program files\someprogram\app.exe" goto exists echo File doesn't exist pause goto exit :exists echo File exists rem *** etc. *** :exit sth like that? for the choice thingy... from DOS 5.0 or 6.0 on there was choice.com (or was it .exe?) that you could use with if errorlevel, ie. it's also included in win9x; but i don't think NT supports it. SET took over this job iirc. check its command line help (set /?) Link to comment Share on other sites More sharing options...
ZippyDo Posted November 17, 2002 Author Share Posted November 17, 2002 Man thanks guys, I am really close, have just one more thing: Heres where I am: @echo Welcome to the Datapass Upgrade for Nov 2002 @echo Press any key to begin the upgrade process if exist "c:\program files\DP Desktop\DPDesktop.exe" goto exists @echo It appears that Datapass is not installed on this system pause goto exit :exists ren "C:\Program Files\DP Desktop\DPDeskTop.exe" DPDeskTop.ex_ Pause Copy x:\DDR\Public\DPDesktop.exe "C:\Program Files\DP Desktop\DPDeskTop.exe" pause :exit Runs and exits appropriately, but after the first two lines are displayed, It lists this: X:\DDR\Public>if exist "c:\program files\DP Desktop\DPDesktop.exe" goto exists It appears that Datapass is not installed on this system X:\DDR\Public>Pause Press any key to continue ... Just like that! Is there a way to remove the top part, and only display the text lines below it? Thanks one last time.... :cry: Link to comment Share on other sites More sharing options...
hurting101 Posted November 17, 2002 Share Posted November 17, 2002 Yes. As mentioned above, just add @echo off to the beginning of the file. Also, if you use @echo off, you don't need to put the @ sign infront of every echo. Link to comment Share on other sites More sharing options...
ZippyDo Posted November 18, 2002 Author Share Posted November 18, 2002 Man, you guys are good....Really enjoy and appreciate the help...Can you tell me if it's possible to perform a search of the "C" drive looking for the particular file and then "ren" all of the instances of file, then copying the new file into their folders...... Link to comment Share on other sites More sharing options...
ilmcuts Posted November 18, 2002 Share Posted November 18, 2002 from the "for" command line help (for /?): FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters] Walks the directory tree rooted at [drive:]path, executing the FOR statement in each directory of the tree. If no directory specification is specified after /R then the current directory is assumed. If set is just a single period (.) character then it will just enumerate the directory tree. I dunno what you mean with "their folders" but for the rest this should work: for /R c:\ %%a in (.) do if exist %%a\myfile.ext ren %%a\myfile.ext newname.txt note that it might take a long time for this statement to complete. it's the best solution i could come up with right now, though there are probably better and faster ones (possibly involving dir /b and a temporary file or some other, probably nested, "for" statements). Link to comment Share on other sites More sharing options...
hurting101 Posted November 19, 2002 Share Posted November 19, 2002 Can you tell me if it's possible to perform a search of the "C" drive looking for the particular file and then "ren" all of the instances of file, then copying the new file into their folders...... I wouldn't recommend this for two reasons: 1) It's slow! Do a dir/b/s \ in command prompt and see what I mean. 2) If they have another unrelated file named with the name you're searching for and you rename it, it could ruin something Link to comment Share on other sites More sharing options...
Recommended Posts