topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Friday March 29, 2024, 7:43 am
  • 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

Author Topic: IDEA! Detect superfluous text & truncate filenames  (Read 9318 times)

skywalka

  • Member
  • Joined in 2005
  • **
  • Posts: 254
    • View Profile
    • Donate to Member
IDEA! Detect superfluous text & truncate filenames
« on: November 21, 2005, 07:32 AM »
If files have their containing folders name as part of their filename is there a program to remove that duplicated text?
 
eg.  I would like the file Alma-Tadema_Lady_Laura_Teresa_Gathering_Pansies.jpg in the folder Alma-Tadema_Lady_Laura_Teresa to be renamed to Gathering_Pansies.
 
Is it possible to detect superfluous text & truncate the filenames?

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA! Detect superfluous text & truncate filenames
« Reply #1 on: November 21, 2005, 03:54 PM »
 :) Try this script!

To run it, download and install AutoHotkey from www.autohotkey.com. Save the script below as RemovePath.ahk and doubleclick to run.

Skrommel

;RemovePath.ahk
SetBatchLines,-1
FileSelectFolder,folderpath
StringSplit,folder_,folderpath,\
foldername:=folder_%folder_0%
Loop,%folderpath%\*.*,0,1
{
  StringGetPos,pos,A_LoopFileName,%foldername%_
  If pos=0
  {   
    StringReplace,filename,A_LoopFileName,%foldername%_,
    FileMove, %folderpath%\%A_LoopFileName%,%folderpath%\%filename%
    ;MsgBox,%filename%`,%A_LoopFileName%`,%foldername%`,%pos%
  }
}
« Last Edit: November 21, 2005, 03:59 PM by skrommel »

skywalka

  • Member
  • Joined in 2005
  • **
  • Posts: 254
    • View Profile
    • Donate to Member
Re: IDEA! Detect superfluous text & truncate filenames
« Reply #2 on: November 22, 2005, 01:19 AM »
Heya Skrommel.

I shoulda known U'd get on this straight away. Thanx! :Thmbsup:

It works just fine.  Would it B possible 2 add support 4 subfolders so that U can rename a whole bunch of folders @ once?  I have a thousand folders that need files renamed.

Thanx again.

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA! Detect superfluous text & truncate filenames
« Reply #3 on: November 22, 2005, 05:18 AM »
 :tellme: I thought the Loop,%folderpath%\*.*,0,1 did recurse folders? Hmmm.

Skrommel

skywalka

  • Member
  • Joined in 2005
  • **
  • Posts: 254
    • View Profile
    • Donate to Member
Re: IDEA! Detect superfluous text & truncate filenames
« Reply #4 on: December 06, 2005, 07:23 PM »
I was referring to processing files within multiple folders on the same path depth.  Not processing files in a folder & it's subfolder.

Also, sometimes folders & files have similar content but not exactly the same 'string'.  eg Surnames can be placed at the beginning of a name followed by a commar.  ie "Billy Bob Thornton" OR "Thornton, Billy Bob".

Is it possible to create a GUI with checkboxes for components to be removed?  eg:
Billy
Bob
Thornton