AandDTechnology123 Posted September 5, 2014 Share Posted September 5, 2014 What I want to do is create a script that will parse a specific file name. I want to create 3 strings to hold values from the parsed values then I need to move to a new directory. Thanks for the help. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 5, 2014 Moderators Share Posted September 5, 2014 Thanks for the lack of information. Can you please give an idea of what the filename looks like, and what you would like the resultant 3 strings to look like? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
AandDTechnology123 Posted September 5, 2014 Author Share Posted September 5, 2014 The file name would be 1234ABC_DEF_GHI, I would want the the strings to be string1=1234ABC, string2=DEF and string3=GHI. I have a directory with may files so it will be given a specific directory to find a file parse the file name and the create a new directory depending on the parsed stings. Thanks for you help. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 5, 2014 Moderators Share Posted September 5, 2014 Look in the help file for StringSplit, it will do what you want. Use "_" as the delimiter to split on. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
AandDTechnology123 Posted September 5, 2014 Author Share Posted September 5, 2014 Great thanks, now how do I get the file name into a string? Link to comment Share on other sites More sharing options...
computergroove Posted September 5, 2014 Share Posted September 5, 2014 Is the filename a file in a directory? Is it the only file in the directory? Do you need to do this with only new files that show up and are they deleted after they are processed by your script? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
AandDTechnology123 Posted September 5, 2014 Author Share Posted September 5, 2014 Yes the filename is in a directory C:TempSUPPORT1234ABC_DEF_GHI.dat. There are up to 50 files in a given directory. This will be will old and new files, the first time it is ran it will have old files and thereafter will be new files, yes they will be deleted after moving them to a new directory and also making a backup file. Link to comment Share on other sites More sharing options...
MikahS Posted September 5, 2014 Share Posted September 5, 2014 Concatenation I presume. $fullString = $string1 + $string2 + $string3 Yours would not look exactly like this, as string split returns an array, not individual string variables. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 5, 2014 Moderators Share Posted September 5, 2014 AandDTechnology123, may I suggest you break this down into pieces. Take the first step first - look at Stringsplit, run the example, and then try to duplicate for your own needs. Then post what you have here, and we can help with the rest. But there is no point in talking to you about all the different ways to accomplish step 5 if you have yet to complete step 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
AandDTechnology123 Posted September 5, 2014 Author Share Posted September 5, 2014 Step 1 is to get the filename into a string to parse and I can not find anything in the help to direct me. Link to comment Share on other sites More sharing options...
kylomas Posted September 5, 2014 Share Posted September 5, 2014 Look at the _filelist* functions in your Help file... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
MikahS Posted September 5, 2014 Share Posted September 5, 2014 (edited) Manually.. Hopefully this gets you to understand the steps needed.. Local $strOpen, $strSplit, $i, $strName $strOpen = FileOpenDialog("get file", @WorkingDir, "all(*.*)") ; select the file you want $strSplit = StringSplit($strOpen, "\") ; split it by \ $i = $strSplit[0] ; get the last value $strName = $strSplit[$i] ; set the file name MsgBox(0, "", $strName) ; tell us Edited September 5, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
mikell Posted September 5, 2014 Share Posted September 5, 2014 Maybe replace in kylomas's comment the * by ToArray() Link to comment Share on other sites More sharing options...
kylomas Posted September 5, 2014 Share Posted September 5, 2014 Or ToArrayRec(), hence the *... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
AandDTechnology123 Posted September 8, 2014 Author Share Posted September 8, 2014 I now have it so I can parse my files but now I am having an issue with StringSplit, it is adding a 1 to the beginning of the first string. Any ideas? $strSplit = StringSplit($aTrimFileName, "_") $aEngineSerialNumber = $strSplit[1] $aLogType = $strSplit[2] $aLogDescription = $strSplit[3] MsgBox(0, "", $aEngineSerialNumber) MsgBox(0, "", $aLogType) MsgBox(0, "", $aLogDescription) Link to comment Share on other sites More sharing options...
kylomas Posted September 8, 2014 Share Posted September 8, 2014 Works for me... local $aTrimFileName = '1234ABC_DEF_GHI' $strSplit = StringSplit($aTrimFileName, "_") $aEngineSerialNumber = $strSplit[1] $aLogType = $strSplit[2] $aLogDescription = $strSplit[3] MsgBox(0, "", $aEngineSerialNumber) MsgBox(0, "", $aLogType) MsgBox(0, "", $aLogDescription) Note - "a" is the defacto prefix for arrays. Your var names are misleading. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
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