Jump to content

Complicated file transfer, unzipping, and editing automation problem


Recommended Posts

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...