Jump to content

renaming files


sbrady
 Share

Recommended Posts

I have a need to create a script that will rename files in a folder. Here is code that I know works to rename.

$original_name = "D:\Promos\AR123 Smith, Bob v1 - FULL MIX.jpg"

$text = StringReplace("AR123 Smith, Bob v1 - FULL MIX.jpg"," - FULL MIX","");AR123 Smith, Bob v1

$new_file_name = StringReplace("AR123 Smith, Bob v1"," v1", " FULL MIX v1.jpg") ;AR123 Smith, Bob FULL MIX v1

$new_filename_path = "D:\Promos\"

FileCopy ($original_name, $new_filename_path & $new_file_name)

Here is what I need:

1. The user may have more than 1 window open.

2. The script will need to be able to navigate to the correct window somehow

3. The files in the window will look like this

AR123 Smith, Bob v1 - Full Mix

AR123 Smith, Bob v1 - SOT Mix

AR123 Smith, Bob v1 - M&E Mix

So, how do I go about this.

1. Can I select the 3 "mix" files and tell the script to rename them

2. Can I tell the script to look in the frontmost of active window, I am not sure how AutoIT will handle this.

3. Is there some other way I dont know about????

4. Be advised the v1 may be v2, v3, v4, v5, v6, v7 , v8.............but the words full mix, SOT mix, and M&E mix wlll be there.

Thanks for any ideas.

Link to comment
Share on other sites

is there a function that gets the items that are selected or highlighted in a folder. I need to rename files at my work all day long. I think it would be easiest if I could get the items that are selected in a window, if not here is what I am thinking.

1. get the name or path of the window that contains the files to be renamed. (winList come to mind)

2. get an array of files whose name contains "mix" (_FIleListToArray comes to mind here)

3. rename the files. (this step I can do successfully)

any help would be appreciated

Link to comment
Share on other sites

  • Moderators

sbrady,

How about sticking to one topic at a time. ;)

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

  • Moderators

sbrady,

Please do not be so impatient - you might think it urgent, but I can assure you that no-one else does. ;)

You might want to look at this post. :)

Or you might want to look at my ChooseFileFolder UDF which will let you select files in an Explorer-like treeview. ;)

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...