How to copy/move files (photos) to folders with part of the file name mask as the destination folder name?

English support forum

Moderators: sheep, Hacker, Stefan2, white

Post Reply
FreeStyler
Junior Member
Junior Member
Posts: 3
Joined: 2019-12-29, 13:35 UTC

How to copy/move files (photos) to folders with part of the file name mask as the destination folder name?

Post by *FreeStyler » 2019-12-29, 15:18 UTC

HI,
I'm looking for possibility to copy / move my photo files to the subfolders in a smart and automated way.

Problem:
I have a lot of files (photos) in one folder. File names have a similar file name scheme. (Usually) the beginning of the file name is the date and time the picture was taken.

YYYYMMDD_hhmmss_XXX.jpg

I am looking for options on how to sort (copy or move) these files to the appropriate folders whose folder names are based on part of the name of the copied file.
Simply put, copy files to folders whose folders names correspond to the date of photos taken.

[YYYYMMDD]

Goal:
Initial, (source) folder:
20191221_134153.jpg
20191222_181130.jpg
20191222_191155_HDR.jpg
20191223_092136_HDR.jpg
20191227_170157.jpg
20191227_170157(0).jpg
20191227_170157(1).jpg
20191227_223325.jpg
....
....

Destination Folder:

[20191221]
20191221_134153.jpg

[20191222]
20191222_134154.jpg
20191222_134155_HDR.jpg

[20191223]
20191223_134156_HDR.jpg

[20191227]
20191227_134157.jpg
20191227_134157(0).jpg
20191227_170157(1).jpg
20191227_223325.jpg
[....]

Thanks in advance!
Any ideas, plugins, scripts are appreciated. I have searched the forum and it seems nothing similar.

User avatar
Stefan2
Power Member
Power Member
Posts: 2717
Joined: 2007-09-13, 22:20 UTC
Location: Europa

MRT: How to move files to folders with part of the file name mask as the destination folder name?

Post by *Stefan2 » 2019-12-29, 17:20 UTC

Hi and welcome, FreeStyler!



FROM:
\TopFld\
|--- 20191221_134153.jpg
|--- 20191222_181130.jpg
|--- 20191222_191155_HDR.jpg
....

TO:
\TopFld\20191221\
|--- 20191221_134153.jpg
\TopFld\20191222\
|--- 20191222_134154.jpg
|--- 20191222_134155_HDR.jpg
....



USE:
Select All: Ctr+A
Launch MRT (multi-rename tool): Ctrl+M

In MRT press F1-key to read more about how to split file name into parts by using the [N] token.
Next you can use an "\"-backslash between the name parts to create folders on the fly and move the files into that folders:     [N1-8]\[N]

Also you can use Search&Replace with [x]RegEx:     Search:(\d{8}).+  ;;;  Replace:$1\\$0





More questions, just ask. 


- - -



FROM:
\TopFld\
|--- 20191221_134153.jpg
|--- 20191222_181130.jpg
|--- 20191222_191155_HDR.jpg
....

TO:
\TopFld\20191221\
|--- 134153.jpg
\TopFld\20191222\
|--- 134154.jpg
|--- 134155_HDR.jpg
....

USE:
[N1-8]\[N10-]
or RegEx: Search: (\d{8}).(.+)   ;;; Replace: $1\\$2




HTH? :D

FreeStyler
Junior Member
Junior Member
Posts: 3
Joined: 2019-12-29, 13:35 UTC

Re: How to copy/move files (photos) to folders with part of the file name mask as the destination folder name?

Post by *FreeStyler » 2019-12-30, 16:34 UTC

Thanks for the support. It works as expected.
I've been using MRT for many years, but never before with the "\". MRT combined with the EXIF plugin gives the very powerful tool.

hi5
Member
Member
Posts: 187
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: How to copy/move files (photos) to folders with part of the file name mask as the destination folder name?

Post by *hi5 » 2019-12-31, 19:34 UTC

Stefan2 wrote:
2019-12-29, 17:20 UTC
Next you can use an "\" between the name parts to create folders on the fly and move the files into that folders:     [N1-8]\[N]
I don't think that is documented or is it? This should be added as I didn't know about it.
F4MiniMenu - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey) - TC Forum thread

User avatar
Dalai
Power Member
Power Member
Posts: 6837
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: How to copy/move files (photos) to folders with part of the file name mask as the destination folder name?

Post by *Dalai » 2019-12-31, 19:51 UTC

hi5 wrote:
2019-12-31, 19:34 UTC
I don't think that is documented or is it?
It is. See TC help (press F1 while in MRT):
Rename mask: file name
[...]
Files can now also be moved to other directories by specifying directory separators "\" (backslashes) in the name. Directories which do not exist yet will be created automatically.
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups

hi5
Member
Member
Posts: 187
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: How to copy/move files (photos) to folders with part of the file name mask as the destination folder name?

Post by *hi5 » 2019-12-31, 20:24 UTC

How could I have missed that? I did search for backslash just now but perhaps typed back slash. Anyway, I checked the history and it is been there since v8.0. Glad I know now but would liked to have know it earlier - but that is my own fault of course :)
F4MiniMenu - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey) - TC Forum thread

Post Reply