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: Like FileSieve but folders have first two letters of file

(1/2) > >>

tabzilla:
FileSieve is a program which puts files into folders named after the first letter of the filename, e.g.,

Abani, Chris - Song for Night
Bach, Richard - Jonathan Livingston Seagull
Caldwell, June - Room Little Darker

becomes

A > Abani, Chris - Song for Night
B > Bach, Richard - Jonathan Livingston Seagull
C > Caldwell, June - Room Little Darker

but if say your S folder still has dozens/hundreds/thousands of files, it would be beneficial to be able to put them in folders named after the first two letters of the file, e.g.,

Sansom, William - The Body
Saravia, Alejandro - Red, Yellow and Green
satyal, rakesh - blue boy
Sloan, Holly Goldberg - Counting By 7s
Sloss, Aria Beth - Autobiography of Us
Slouka, Mark - Brewster
Swartwood, Robert - Hint Fiction
Sweeney, Kate - The O'Malley Legacy
Swift, Graham - Shuttlecock

becomes

SA > Sansom, William - The Body
SA > Saravia, Alejandro - Red, Yellow and Green
SA > Satyal, Rakesh - Blue Boy
SL > Sloan, Holly Goldberg - Counting By 7s
SL > Sloss, Aria Beth - Autobiography of Us
SL > Slouka, Mark - Brewster
SW > Swartwood, Robert - Hint Fiction
SW > Sweeney, Kate - The O'Malley Legacy
SW > Swift, Graham - Shuttlecock

FileSieve doesn't seem to do that and I've been unable to find any program which does.  So far I've been doing it by using Bulk Rename Utility to remove the first letter before using FileSieve then putting it back on with BRU after.

Many thanks.

Nod5:
This should do it.


--- Code: Autohotkey ---#NoEnvSetWorkingDir %A_ScriptDir%#SingleInstance force ;AutoHotkey script to move files into subfolders named after the filename's first two characters;by Nod5 2019-10-08 ;How to use:;0. install https://www.autohotkey.com/ ;1. edit the next line with a path to the files folder. For example "C:\folder\S"folder := "";2. save the script with .ahk extension and UTF-8 BOM encoding and run it ;Check that the folder existsIf !InStr( FileExist(folder), "D")  ExitApp Loop, Files, %folder%\*.*{  tooltip `n Moving files into subfolders ...   ;get filename's first two characters as uppercase  two_chars := SubStr(A_LoopFileName, 1, 2)  two_chars := Format("{:U}", two_chars)   ;create subfolder if not already exists  If !FileExist(folder "\" two_chars)    FileCreateDir % folder "\" two_chars   ;move file to subfolder  FileMove, % A_LoopFilePath, % folder "\" two_chars}ExitApp

In addition another script to generate a bunch of empty text files for testing/troubleshooting the above script


--- Code: Autohotkey ---#NoEnvSetWorkingDir %A_ScriptDir%#SingleInstance force ;AutoHotkey script to generate 75 empty text files named with the format;sa_1.txt , sa_2.txt , sa_3.txt , sb_1.txt ...  chars := "abcdefghijklmnopqrstuvxyz"test_folder := A_ScriptDir "\" A_NowFileCreateDir, % test_folderLoop, Parse, chars  Loop, 3    FileAppend,, % test_folder "\s" A_LoopField "_" A_Index ".txt"ExitApp

tabzilla:
It's working perfectly.  Thank you very much.

tabzilla:
If you wanted to name the folders after everything before " - ", e.g.,

Achebe, Chinua - There Was a Country
Achebe, Chinua - Things Fall Apart
Adiga, Aravind - Last Man in Tower
Adiga, Aravind - The White Tiger
Alger, Horatio - Bound to Rise
Alger, Horatio - Driven From Home

becoming

Achebe, Chinua > Achebe, Chinua - There Was a Country
Achebe, Chinua > Achebe, Chinua - Things Fall Apart
Adiga, Aravind > Adiga, Aravind - Last Man in Tower
Adiga, Aravind > Adiga, Aravind - The White Tiger
Alger, Horatio > Alger, Horatio - Bound to Rise
Alger, Horatio > Alger, Horatio - Driven From Home

would that be a matter of modifying the above script or is it more complicated than that?

Thanks again.

tabzilla:
I figured out how to change the folder names to the first three characters or first single character but incorporating a regex or anything was beyond me from just looking at other examples.

Navigation

[0] Message Index

[#] Next page

Go to full version