hgreanias Posted June 18, 2012 Share Posted June 18, 2012 So I am new to coding outside of VBA / SQL, and have been trying to figure out a way to automate the following: 1. Transfer all files from a folder (folder1), to another folder (folder 2), AND be able to specify two constraints for the names of the files to be transferred. For Example: I want to be able to specify to transfer all files containing both "MDXv3" and "_2012" in their file name, and I am thinking of something close to the LIKE '%abcd'; function from SQL 2. After the specified files have been transferred from folder1 to folder2, I need to unzip all the files in folder2 using 7zip (extraction location is folder2) 3. After extracting the files, I want to have it automatically delete all files ending in ".dec" and then edit part of the name out of all the files ending in ".txt" for example: I would want to be able to specify that "145_" is to be deleted from the file name of every ".txt" file My goal here is to automate the transferring, unzipping and editing of extracted files. I need to have a macro for this because I am only looking for specific files in folder 1, say 350 files, but there are some 10k+ files, and the files I am looking for are not named in an easily organized fashion (this is done out of necessity, not choice so I am unable to change the original archiving file names of the files I am working with) So far I have been trying to use a macro recorder to do this but the task is a bit too complicated for a simple recording Thank you for the help ahead of time, I really have been struggling with this Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 18, 2012 Moderators Share Posted June 18, 2012 hgreanias,Welcome to the AutoIt forum. What you want to do sounds long, but it is not particularly difficult: - 1. Use _FileListToArray to list the files in folder1 and then loop through them using StringInStr to determine whether they meet you naming criteria - if they do then FileMove them to folder2.- 2. There is a 7-Zip UDF somewhere on the forum which should help you with the next part - or you could use Run to extract the files using the 7-Zip exectuable directly.- 3. Use _FileListToArray on the extracted files, looping through the returned array to action as required (FileDelete or FileMove to rename) depending on the filename.As I said, a longish process, but not overly difficult. Take a look at the functions I have mentioned and see what you can come up with - you know where we are if you run into difficulties. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Wena Posted June 18, 2012 Share Posted June 18, 2012 Hi HgreaniasSearch for [sOLVED]-Search for part of a line in text file and replace with new line.It should be what you are looking for.If it is you can thank Melba23.Wena 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