ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

IDEA! Detect superfluous text & truncate filenames

(1/1)

skywalka:
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:
 :) 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%
  }
}

skywalka:
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:
 :tellme: I thought the Loop,%folderpath%\*.*,0,1 did recurse folders? Hmmm.

Skrommel

skywalka:
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

Navigation

[0] Message Index

Go to full version