onefish Posted August 16, 2005 Posted August 16, 2005 I need to produce a unique identifier for the purposes of moving files with a static path/name to a different path/name. I have written a script that uses a timestamp variable to acomplish this and it works quite well for what it was intended. I now need to generate a script that will move a pdf file from a static path/name to a different path/name and then run the PDF viewer program.exe (which may vary) and open the file that was just moved. The name must be unique to enable the move to take place without overwriting. Two questions if anyone can help: 1. Will the globale timestamp variable I have used previously to name the file change within the same script or is it called one time at the begining of the script and remains the same for all occasions of the variable throughout the script? If there is a better way to accomplish the unique identifier within the script please let me know. I am having trouble passing command line parameters so would like to stay away from them if possible. 2. What is the best way to run the users default PDF viewer? This will only be my second AutoIT script so please forgive me if the answers to my questions are obvious.
w0uter Posted August 16, 2005 Posted August 16, 2005 1: set your timestamp to a variable. and for a real check use FileExist. 2: @comspec is easyest, dllcall & com are better ways. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
/dev/null Posted August 16, 2005 Posted August 16, 2005 1. Will the globale timestamp variable I have used previously to name the file change within the same script or is it called one time at the begining of the script and remains the same for all occasions of the variable throughout the script? What "timestamp" variable did you use? Could you please post some code?If there is a better way to accomplish the unique identifier within the script please let me know. I am having trouble passing command line parameters so would like to stay away from them if possible.You could use _TempFile(). Must include file.au3 (see help file for _TempFile()).2. What is the best way to run the users default PDF viewer?in a dos box: start test.pdf. In AutoIT: Run() or RunWait() with "start".NOT tested!$filename = "c:\test.pdf" RunWait(@ComSpec & " /c " & "start " & $filename)This will only be my second AutoIT script so please forgive me if the answers to my questions are obvious.No problem.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
onefish Posted August 17, 2005 Author Posted August 17, 2005 Thank you for the advice. The _TempFile() function should do the trick to name the file. I'll run some tests now to see how the variables act throughout the script. It may not be an issue. The timestamp variable I am using is: $vari1 = @HOUR & "'" & @MIN & "'" & @SEC & "_"& @MDAY & "'" & @MON & "'" & @YEAR It seams to work well. Will give your code a try now Kurt. Cheers
onefish Posted August 17, 2005 Author Posted August 17, 2005 (edited) I can't seam to get the @ComSpec method to work. Error - windows cannot find the file. I imagine I am not using the correct syntax. I have tried the full file path "Documents and Settings\TJOHO\Personal\0968_zones_v11.pdf", the name only and everything in between in the example script above but no luck. What am I doing wrong? I would prefer not to have to specify AcroRd32.exe as some users may prefer another PDF reader (there are much better ones). Script is: $filename = "Documents and Settings\TJOHO\Personal\0968_zones_v11.pdf" Run(@COMSPEC & " /c Start "& $filename) Edited August 17, 2005 by onefish
LxP Posted August 17, 2005 Posted August 17, 2005 "Documents and Settings\TJOHO\Personal\0968_zones_v11.pdf" is not a full path. Try using "\Documents and Settings\TJOHO\Personal\0968_zones_v11.pdf" or alternatively you might find @UserProfileDir & "\Personal\0968_zones_v11.pdf" better to do what you want.
onefish Posted August 17, 2005 Author Posted August 17, 2005 I think I figured it out. Windows doesn't like spaces in the file name/path. It can't find Documents and Settings. When I put the file in C:\temp no problem. Using the same script. Is there a protocal for declaring spaces in the file name/path?
seandisanti Posted August 17, 2005 Posted August 17, 2005 I think I figured it out. Windows doesn't like spaces in the file name/path. It can't find Documents and Settings. When I put the file in C:\temp no problem. Using the same script. Is there a protocal for declaring spaces in the file name/path?<{POST_SNAPBACK}>i don't think it's an issue with the spaces as it is an issue with the path as LXP pointed out. try throwing a "C:\" infront of the string that's not working and see if that works.
/dev/null Posted August 17, 2005 Posted August 17, 2005 i don't think it's an issue with the spaces as it is an issue with the path as LXP pointed out. try throwing a "C:\" infront of the string that's not working and see if that works.<{POST_SNAPBACK}>@cameronsdad: Both are right. The path was not correct in the first run and there is a problem with spaces in file names when you start a program in a dos box, because the command interpreter cannot distinguish between the filename and a commandline argument.start c:\my dir\test.pdf could be just on commandline parameter (the filename c:\my dir\test.pdf) or two, a path (c:\my) and something else (dir\test.pdf).@onefish: Declare your path variable as follows (single quote followed by double quote!).$filename = '"C:\Documents and Settings\TJOHO\Personal\0968_zones_v11.pdf"'. This will create the following command: start "C:\Documents and Settings\TJOHO\Personal\0968_zones_v11.pdf". Now, the command interpreter knows what to do....CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
onefish Posted August 17, 2005 Author Posted August 17, 2005 Thanks Kurt, I had included c:\ in the script and every other drive I have to try and get the script to work prior to posting. But I forgot to include the drive letter in my posted script, oops. Thanks for the advice, it works well. The @ComSpec macro generates a visible command interpretor window. It's only for a flash but I was wondering if there is a way to keep it hidden?
w0uter Posted August 17, 2005 Posted August 17, 2005 @sw_HIDE. see the doc. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
onefish Posted August 18, 2005 Author Posted August 18, 2005 (edited) Works- $vari = "c:\ICHMStemp\ICHMS.pdf" Run(@ComSpec & " /c Start " & $vari ) doesn't work- $vari = "c:\ICHMStemp\ICHMS.pdf" Run(@ComSpec & " /c Start " & $vari , @sw_HIDE ) It appears @sw_HIDE is being interpreted as part of the file name/path. What am I doing wrong? Edited August 18, 2005 by onefish
onefish Posted August 18, 2005 Author Posted August 18, 2005 OK got it working by adding another null value $vari = "c:\ICHMStemp\ICHMS.pdf" Run(@ComSpec & " /c Start " & $vari , "", @SW_HIDE ) Thank you all for your assistance.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now