topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday October 14, 2024, 6:56 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: IDEA: Find filenames/folders above certain length and offer to rename them  (Read 109026 times)

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
not sure if there's been a solution or not (it's vewy vewy quiet out there...) but here's my work on this so far - apologies if the code is untidy, but it is a work in progress

Basic functionality only so far, ie you can only edit a single file at a time. 

Select a folder using the add files button.  Files are filtered by the number of characters in the file name (excluding the xtn) using the spinner at the top.  Multiple folders can be added (folders are included in the list)

F2 or double click to edit the selected item (only)

ToDo -

capture single click (x2) editing

Preconfigured rules - I thought about the suggestions for this and it seemed they could be distilled down to a couple of basic rules, ie Trim Left, Trim Right, and replace custom.  I envisage Custom as being a comma separated list of characters/strings to remove from a file name (each character/string would be removed sequentially) - this is potentially problematic as the initial actions may create unintentionial matches for subsequent actions

any thoughts/suggestions/feedback (am I on the right track here??)

EDIT - removed old attachment
« Last Edit: March 23, 2009, 05:37 PM by Target »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
wow! this is nice Target. :up: i've play around and i've noticed that pressing F2 on the 1st item puts the word 'File' in the rename dialog. the rest works okay with the filename in the dialog. also can you add a refresh button, for updating the view as the user increase/decrease the character limit.

i'll be back with more feedback. btw, attaching a screenshot:

File_renamer-1.pngIDEA: Find filenames/folders above certain length and offer to rename them


edit: if the script is running, other app can't use F2. just letting you know.

« Last Edit: March 16, 2009, 09:00 PM by lanux128 »

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
try this then...
  • fixed (?) the issue with editing the first entry
  • added a refresh button (doing this automagically for a spinner isn't going to work)
  • added some sample functionality to the trim functions (it changes the values in the list, but that's all).  This isn't complete as it doesn't loop through the list yet (i'm getting there...)
 

Not sure about confining the hotkey to that app (I usually try and pick unique keys), it must be doable but I'll have to see what I can find out
« Last Edit: March 16, 2009, 10:57 PM by Target »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
  • fixed (?) the issue with editing the first entry
  • added a refresh button (doing this automagically for a spinner isn't going to work)
  • added some sample functionality to the trim functions (it changes the values in the list, but that's all).  This isn't complete as it doesn't loop through the list yet (i'm getting there...)

yes, (1) is fixed and the refresh button is nice. also can you add an edit box the folder select box? i normally copy-paste the path. also i assume that 'Apply' button is not functioning yet (?)

Not sure about confining the hotkey to that app (I usually try and pick unique keys), it must be doable but I'll have to see what I can find out

i tried the #IfWinActive command but the rename dialog is suppressed instead.

#IfWinActive File_renamer.ahk ahk_class AutoHotkeyGUI

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
the apply button works but only in a limited fashion, ie I've added some sample functionality to the trim functions. 

To play with it just check a box (both at once if you like) and hit apply.  The results are displayed in the list only so you can't do any damage...

quite a bit more work to do with that side of things yet...

added an edit box to paste a path AND drop file functionality (drop a folder on the gui to load it - you need to set your string length first, or set it and refresh it afterwards)
 
haven't had a chance to look at the hotkey issue (I may be able to get to it later on tonight, or in the morning) 

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
the trim functions are working quite well on files but on the folders. just letting you know, i know it's still WIP. thanks for adding the path box, but a message pops up when i press 'Add files' button.

another way to do it is to add in this line:
FileSelectFolder, OutputVar, StartingFolder, 2

where '2' means "to provide an edit field that allows the user to type the name of a folder".

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
not sure if there's been a solution or not (it's vewy vewy quiet out there...)

Apologies, Lanux128 and Target.  I've been busy with Trout code, PlayTime code, both daughter's soccer games and my own hockey games.  =]  It looks like Target has you well in hand.

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
yeah, folders might be a bit of problem (if you change a folder name, all the filepaths are changed as well...)

sorry, thought that was what you were asking for as a feed for adding folders (the messagebox was for debugging so it can safely be ignored).  Thinking about it a bit more though I can see a number of problems with this approach (so out it goes... :huh:)

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
[Apologies, Lanux128 and Target.  I've been busy with Trout code, PlayTime code, both daughter's soccer games and my own hockey games.  =]  It looks like Target has you well in hand.

no apologies necessary, you gotta do what you gotta do!!

not sure if I'd say I had this in hand though, it's more like a tenous grip on one edge...

I was kinda looking forward to your solution though (I have no doubt it would be both more elegant and more capable than mine)

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
I was kinda looking forward to your solution though (I have no doubt it would be both more elegant and more capable than mine)
Okay, I'll start writing it.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
yeah, folders might be a bit of problem (if you change a folder name, all the filepaths are changed as well...)

if the folders are too much of a problem then renaming could be restricted to files only but display the folder length as well.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
I was kinda looking forward to your solution though (I have no doubt it would be both more elegant and more capable than mine)
Okay, I'll start writing it.

thanks skwire, looking forward to that version as well. Target, i hope you will soldier on.

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
further update...
  • F2 Hotkey - not fixed, but changed to WIN+F2 in the interim (this gives F2 back to your other applications)
  • sample functionality for Trim AND custom

the script now loops through the selected items and performs whatever actions you have checked on the right hand side. Some care is needed with the custom function as it initial actions may create unintentional matches for subsequent actions.  NOTE - the actions you specify do not have any impact on the actual files at this point.  The functionality is intended for testing and evaluation purposes only

todo -
  • recognises overlapping trims, ie where the total characters trimmed exceed the number of characters in a given file name
  • fix the hotkey issue
  • convert the sample functionality into something useful
  • clean up/rationalise the gui
over to you...

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
lanux128, here's my take:  Name Knife

At this point, it does no renaming whatsoever; it's more of a proof of concept for the GUI.  Before I go further, please let me know if this is what you had in mind.  I tried it make it look like your example post from above.  Thanks.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
the script now loops through the selected items and performs whatever actions you have checked on the right hand side. Some care is needed with the custom function as it initial actions may create unintentional matches for subsequent actions.  NOTE - the actions you specify do not have any impact on the actual files at this point.  The functionality is intended for testing and evaluation purposes only

yes, i can see that trimming can cause certain files to have the same truncated file-names. it's a good idea that you are testing all possibilities before committing to the actual renaming. :up:

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
lanux128, here's my take:  Name Knife

At this point, it does no renaming whatsoever; it's more of a proof of concept for the GUI.  Before I go further, please let me know if this is what you had in mind.  I tried it make it look like your example post from above.  Thanks.

thanks for the script. i've been trying it out and it looks and feels almost like the prototype but 'max file/folder name length' option confuses me. when i choose the length from the drop-down, all files in the list-view disappear, why is that? also a refresh button would be nice for updating the view as the user increase/decrease the character limit.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
thanks for the script. i've been trying it out and it looks and feels almost like the prototype but 'max file/folder name length' option confuses me. when i choose the length from the drop-down, all files in the list-view disappear, why is that?
What?  Simply choosing a value from the dropdown shouldn't make any listview contents disappear.  Now, if you set it BEFORE choosing a folder, those results will be filtered.  Maybe this is what you're seeing?

also a refresh button would be nice for updating the view as the user increase/decrease the character limit.
A refresh button is already in my next build.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
thanks for the script. i've been trying it out and it looks and feels almost like the prototype but 'max file/folder name length' option confuses me. when i choose the length from the drop-down, all files in the list-view disappear, why is that?
What?  Simply choosing a value from the dropdown shouldn't make any listview contents disappear.  Now, if you set it BEFORE choosing a folder, those results will be filtered.  Maybe this is what you're seeing?

now i understand that the results are filtered, in this case maybe a status-bar update would be useful confirming that none of the files exceed the given length.

thanks for the refresh button plus another feature req: retention of the last few chosen folder as a drop-down. :)


skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
now i understand that the results are filtered, in this case maybe a status-bar update would be useful confirming that none of the files exceed the given length.
Added.  Re-download.  Name Knife

another feature req: retention of the last few chosen folder as a drop-down.
Obviously, this will entail an INI file for saving purposes.  Cool?
« Last Edit: March 18, 2009, 04:41 AM by skwire »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
thanks, downloading the newer version. i'm good with the INI file solution. :up:

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Updated.  Re-download, please.  Name Knife

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
sorry there seems to be an error.

name_knife-error.pngIDEA: Find filenames/folders above certain length and offer to rename them


skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
sorry there seems to be an error.
Update to the latest AutoHotkey.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Update to the latest AutoHotkey.

oops! :-[

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Is that look and feel what you had in mind?  Once we get this to where you want, I'll go ahead with the actual renaming code.
« Last Edit: March 18, 2009, 08:52 AM by skwire »