Multi-Rename: get File count and rename folder with ?
Moderators: white, Hacker, petermad, Stefan2
-
- Junior Member
- Posts: 80
- Joined: 2016-10-26, 20:04 UTC
Multi-Rename: get File count and rename folder with ?
Hello everyone
is this possible? (With plugins or other)
Count file in folder (with filter for photo, video, program, doc, etc) and rename folder with count number
Example folder with images:
Before
Folder
After
Folder (16 images)
is this possible? (With plugins or other)
Count file in folder (with filter for photo, video, program, doc, etc) and rename folder with count number
Example folder with images:
Before
Folder
After
Folder (16 images)
Sure. Get DirSizeCalc plugin, install it, open MRT and use something like
See the "[=? Plugin]" button for other plugin fields and stuff.
Regards
Dalai
Code: Select all
[N] ([=dirsizecalc.File Count])
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
-
- Junior Member
- Posts: 80
- Joined: 2016-10-26, 20:04 UTC
Hi Dalai
I've already installed this plugin
What I want to do is different
1) counting files within the folder
2) physically rename the folder with count results
example:
First the folder has this name
Folder
After counting (by content) rename the folder so
Folder (16 images)
ps:
The link to the plugin is wrong
download
http://lefteous.totalcmd.net/tc/dirsizecalc_eng.htm
forum topic
https://www.ghisler.ch/board/viewtopic.php?t=18021&postdays=0&postorder=asc&start=0&sid=17d1b5adb19b6221130aaa732cd8994c
I've already installed this plugin
What I want to do is different
1) counting files within the folder
2) physically rename the folder with count results
example:
First the folder has this name
Folder
After counting (by content) rename the folder so
Folder (16 images)
ps:
The link to the plugin is wrong
download
http://lefteous.totalcmd.net/tc/dirsizecalc_eng.htm
forum topic
https://www.ghisler.ch/board/viewtopic.php?t=18021&postdays=0&postorder=asc&start=0&sid=17d1b5adb19b6221130aaa732cd8994c
PowerShell: rename folder with number of files inside
You can use your OS scripting tool to accomplish that:
PowerShell
- See your windowsTM start menu to launch PowerShellTM
- Navigate to your "main" folder.
(You can open a "DOS-Box" in TC and execute there the command Powershell to get a PoSh console in the right directory)
- Type or copy in this command line:
Get-ChildItem -Directory | ForEach-Object{ Rename-Item $_ ($_.Name + " ({0} Files)" -f (GCI $_\* -File -Include *.jpg,*.vbs,*.TXT).count) }
- maybe adjust it to your needs.
Explanations:
Rename-Item $_ ( ... ) will rename each processed folder with original Name plus " ({0} Files)"
where {0} is replaced by the math done with (GCI $_\* -File -Include *.jpg,*.vbs,*.TXT).count)
where GCI is short for Get-ChildItem.
For more info just ask
or see https://www.google.de/search?q=powershell+for+beginners
- - -
I have tested this by using abbreviated commands:
Command line
ls -Dir|%{ren $_ ($_.Name + " ({0} Files)" -f (ls $_\* -File -Inc *.jpg,*.vbs,*.TXT).count)}
Test folder 1 (0 Files)\
Test folder 2 (14 Files)\
Test folder 3 (0 Files)\
Test folder 4 (4 Files)\
Test folder 5 (4 Files)\
Test folder 6 (3 Files)\
Test folder 7 (21 Files)\
Test folder 8 (0 Files)\
Test folder 9 (0 Files)\
Test folder 10 (4 Files)\
Test folder 11 (4 Files)\
Test folder 12 (0 Files)\
- - -
To count files in sub sub-folders also, use
GCI $_\* -Recurse -Include
instead off
GCI $_\* -File -Include
So use:
Command line
ls -Dir|%{ren $_ ($_.Name + " ({0} Files)" -f (ls $_\* -Rec -Inc *.jpg,*.vbs,*.TXT).count)}
Test folder 1 (0 Files) (2 Files)\
Test folder 2 (14 Files) (14 Files)\
Test folder 3 (0 Files) (0 Files)\
Test folder 4 (4 Files) (4 Files)\
Test folder 5 (4 Files) (7 Files)\
Test folder 6 (3 Files) (6 Files)\
Test folder 7 (21 Files) (40 Files)\
Test folder 8 (0 Files) (3 Files)\
Test folder 9 (0 Files) (0 Files)\
Test folder 10 (4 Files) (16 Files)\
Test folder 11 (4 Files) (4 Files)\
Test folder 12 (0 Files) (0 Files)\
^^^ that is the result of two runs, one after the other ^^^
.
PowerShell
- See your windowsTM start menu to launch PowerShellTM
- Navigate to your "main" folder.
(You can open a "DOS-Box" in TC and execute there the command Powershell to get a PoSh console in the right directory)
- Type or copy in this command line:
Get-ChildItem -Directory | ForEach-Object{ Rename-Item $_ ($_.Name + " ({0} Files)" -f (GCI $_\* -File -Include *.jpg,*.vbs,*.TXT).count) }
- maybe adjust it to your needs.
Explanations:
Rename-Item $_ ( ... ) will rename each processed folder with original Name plus " ({0} Files)"
where {0} is replaced by the math done with (GCI $_\* -File -Include *.jpg,*.vbs,*.TXT).count)
where GCI is short for Get-ChildItem.
For more info just ask
or see https://www.google.de/search?q=powershell+for+beginners
- - -
I have tested this by using abbreviated commands:
Command line
ls -Dir|%{ren $_ ($_.Name + " ({0} Files)" -f (ls $_\* -File -Inc *.jpg,*.vbs,*.TXT).count)}
Test folder 1 (0 Files)\
Test folder 2 (14 Files)\
Test folder 3 (0 Files)\
Test folder 4 (4 Files)\
Test folder 5 (4 Files)\
Test folder 6 (3 Files)\
Test folder 7 (21 Files)\
Test folder 8 (0 Files)\
Test folder 9 (0 Files)\
Test folder 10 (4 Files)\
Test folder 11 (4 Files)\
Test folder 12 (0 Files)\
- - -
To count files in sub sub-folders also, use
GCI $_\* -Recurse -Include
instead off
GCI $_\* -File -Include
So use:
Command line
ls -Dir|%{ren $_ ($_.Name + " ({0} Files)" -f (ls $_\* -Rec -Inc *.jpg,*.vbs,*.TXT).count)}
Test folder 1 (0 Files) (2 Files)\
Test folder 2 (14 Files) (14 Files)\
Test folder 3 (0 Files) (0 Files)\
Test folder 4 (4 Files) (4 Files)\
Test folder 5 (4 Files) (7 Files)\
Test folder 6 (3 Files) (6 Files)\
Test folder 7 (21 Files) (40 Files)\
Test folder 8 (0 Files) (3 Files)\
Test folder 9 (0 Files) (0 Files)\
Test folder 10 (4 Files) (16 Files)\
Test folder 11 (4 Files) (4 Files)\
Test folder 12 (0 Files) (0 Files)\
^^^ that is the result of two runs, one after the other ^^^
.
Last edited by Stefan2 on 2017-06-19, 10:08 UTC, edited 2 times in total.
-
- Junior Member
- Posts: 80
- Joined: 2016-10-26, 20:04 UTC
Re: PowerShell: rename folder with number of files inside
Stefan2 wrote:You can use your OS scripting tool to accomplish that:
PowerShell
.
Hi Stefan2
I do not know PowerShell
How to make it work?
Do i have to create a file?
ps:sorry for my English
Well, that depends on the folder's contents.Alexisback wrote:What I want to do is different
I don't see any problem here, i.e. MRT can do that in conjunction with DirSizeCalc plugin.1) counting files within the folder
2) physically rename the folder with count results
To get this straight: DirSizeCalc can count files, and you can use this plugin (and any other content plugin) in MRT to rename the directories. It depends on whether or not you have other files in this directories, too. If you have only pictures in the directories you want to rename to "dir_name (X images)" you can use the method no problem. If you have other files, such as text, docs, etc in these directories as well, my method won't work well, because DirSizeCalc counts files regardless of their extension (file type).
No, it's not. It's another download source for this plugin, as it is for many other plugins.ps:
The link to the plugin is wrong
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
-
- Junior Member
- Posts: 80
- Joined: 2016-10-26, 20:04 UTC
Hi DalaiDalai wrote:I don't see any problem here, i.e. MRT can do that in conjunction with DirSizeCalc plugin.Alexisback wrote:What I want to do is different
You're right, I did not read that i have to open MRT (my mistake)
This method works
The problem is this:
If there are 16 images in the folder and 2 different files (.txt, .doc)
I want it to count only 16 pictures (and rename the folder)
ps:
If I open this link to me by mistake
http://totalcmd.net/plugring/dirsizecalc.html
404 Not Found:
Not Found
The requested URL /plugring/dirsizecalc.html was not found on this server.
thanks
Try https://totalcmd.net/plugring/dirsizecalc.html (https://...Alexisback wrote:ps:
If I open this link to me by mistake
http://totalcmd.net/plugring/dirsizecalc.html
404 Not Found:
Not Found
The requested URL /plugring/dirsizecalc.html was not found on this server.
thanks