Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • December 08, 2016, 02:15:22 PM
  • Proudly celebrating 10 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 6238 times)

skywalka

  • Member
  • Joined in 2005
  • **
  • Posts: 253
    • View Profile
    • Donate to Member
IDEA! Detect superfluous text & truncate filenames
« on: November 21, 2005, 07:32:11 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: 886
    • 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:30 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%
  }
}
Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
« Last Edit: November 21, 2005, 03:59:25 PM by skrommel »

skywalka

  • Member
  • Joined in 2005
  • **
  • Posts: 253
    • View Profile
    • Donate to Member
Re: IDEA! Detect superfluous text & truncate filenames
« Reply #2 on: November 22, 2005, 01:19:00 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: 886
    • 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:36 AM »
 :tellme: I thought the Loop,%folderpath%\*.*,0,1 did recurse folders? Hmmm.

Skrommel
Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.

skywalka

  • Member
  • Joined in 2005
  • **
  • Posts: 253
    • View Profile
    • Donate to Member
Re: IDEA! Detect superfluous text & truncate filenames
« Reply #4 on: December 06, 2005, 07:23:06 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