topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Thursday March 28, 2024, 9:36 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

Author Topic: Check file/folder similarity, rename file when similiraty occurs  (Read 11301 times)

Coldiffusion

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 11
    • View Profile
    • Donate to Member
I will try to explain my needs simply.

I'm looking for a script/soft which search in a specific folder (and all subfolders) for this :

examplefile1.msf (file with .msf extension)
examplefile1 (file with no extension)
examplefile1.sbd (simple folder)

In this situation the script would be able to detect there is a folder which have the same of a file. (like in the example up there)
and the script would rename the "file1.msf" to "file1.msf.old"

Basicaly it would to that :

-> you launch the soft/script
-> it ask for a folder's path
-> the script check for the similarity I explained up there

if

-> there is a file (.msf) who have the same name than a folder (finishing with .sbd) : it add .old to the extension (example = file.msf.old) or rename (if it's easier) the file from .msf to .old (example = file.old)

-> there is no folders which have the same name : nothing happens


Thanks !
 

fenixproductions

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,186
    • View Profile
    • Donate to Member
Re: Check file/folder similarity, rename file when similiraty occurs
« Reply #1 on: August 25, 2008, 07:18 AM »
2Coldiffusion
If you are Total Commander's user then you can use Similarity.wdx plugin.
Just take a look here:
http://fenixproducti...Plugins.aspx#similar

If you don't *maybe* I will write it as standalone tool.
« Last Edit: September 30, 2008, 03:56 PM by fenixproductions »

Coldiffusion

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 11
    • View Profile
    • Donate to Member
Re: Check file/folder similarity, rename file when similiraty occurs
« Reply #2 on: August 25, 2008, 07:35 AM »
I took a brief look at total commander, it seems like a very powerful tool, 

the problem is I intend to distribute the soft/script to many users (dozens, hundred dont know yet) and I try to keep it simple for them, click here, click here, click here and voila

Anyway if you decide to take some time to write a standalone tool for me, you will be rewarded for your work.

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: Check file/folder similarity, rename file when similiraty occurs
« Reply #3 on: August 25, 2008, 07:19 PM »
 :) Try this AutoHotkey script!

Almost untested, so please test it before you distribute it or use it on any vital files.

Skrommel

FileSelectFolder,folder,,2,Please select a folder
If folder=
  ExitApp
Loop,%folder%\*.msf,0,1
{
  SplitPath,A_LoopFileLongPath,name,dir,ext,name_no_ext,drive
  IfExist,%dir%\%name_no_ext%.sbd
  {
    FileGetAttrib,attrib,%dir%\%name_no_ext%.sbd
    IfInString,attrib,D
      FileMove,%dir%\%name_no_ext%.msf,%dir%\%name_no_ext%.msf.old
  }
}
« Last Edit: August 26, 2008, 01:43 AM by skrommel »

Coldiffusion

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 11
    • View Profile
    • Donate to Member
Re: Check file/folder similarity, rename file when similiraty occurs
« Reply #4 on: August 26, 2008, 01:40 AM »
Thanks for quick answer !

Just tested your script skrommel, working nice without any problems.

There are just 2 things I would like to see changed (if it's possible)



The text in red, being able to change it (with a ini file ?)
Remove the blue option (in english : "create new folder")


skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: Check file/folder similarity, rename file when similiraty occurs
« Reply #5 on: August 26, 2008, 01:43 AM »
 :) Done!

Skrommel

Coldiffusion

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 11
    • View Profile
    • Donate to Member
Re: Check file/folder similarity, rename file when similiraty occurs
« Reply #6 on: August 26, 2008, 01:54 AM »
Fastest code in the west
Developer


I confirm  :-*

Thanks you !

VideoInPicture

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 467
    • View Profile
    • Circle Dock
    • Donate to Member
Re: Check file/folder similarity, rename file when similiraty occurs
« Reply #7 on: August 26, 2008, 03:13 AM »
I see I'm a bit late. I saw this thread a few hours before but was busy coding other stuff.

Here's my solution to the problem:
MSF_Restruct.JPGCheck file/folder similarity, rename file when similiraty occurs1

It is written in C# and requires .Net Framework 2.0 which is already on all Vista computers and most XP computers that use Windows Update. Just double-click the MSF_FileRestructurer.exe file and the GUI will pop up.

The code copies the source directory into a new directory and then processes that new directory so there is no chance of something going wrong. It also has some error checking in the code just in case some file is being used or locked by the system so it doesn't crash while it is running. You can also stop the program while it is in the middle of running. There is progress bar that tells you how far along it is and an error message box that tells you any errors that pop up. I have tested the program using a test directory I created that is included in the file.

Source code is included.
Author of Circle Dock: http://circledock.wikidot.com
Author of Video In Picture: http://videoinpicture.wikidot.com
Author of Webcam Signature: http://webcamsignature.wikidot.com
Author of Easy Unicode Paster: http://easyunicodepaster.wikidot.com

Coldiffusion

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 11
    • View Profile
    • Donate to Member
Re: Check file/folder similarity, rename file when similiraty occurs
« Reply #8 on: August 26, 2008, 03:27 AM »
Thanks VideoInPicture but skrommel already did a autohotkey which working nice  :-[

FileSelectFolder,folder,,2,Please select a folder
If folder=
  ExitApp
Loop,%folder%\*.msf,0,1
{
  SplitPath,A_LoopFileLongPath,name,dir,ext,name_no_ext,drive
  IfExist,%dir%\%name_no_ext%.sbd
  {
    FileGetAttrib,attrib,%dir%\%name_no_ext%.sbd
    IfInString,attrib,D
      FileMove,%dir%\%name_no_ext%.msf,%dir%\%name_no_ext%.msf.old
  }
}

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Check file/folder similarity, rename file when similiraty occurs
« Reply #9 on: August 26, 2008, 05:32 PM »
Nice work both of you!

What kind of crazy place is this where there are not one but 2 solutions posted for a request in 24 hours  :o :o :o