This forum uses cookies. Click X button to hide this message. What is stored? 
Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multi-Rename: get File count and rename folder with ?

 
Post new topic   Reply to topic    Total Commander Forum Index -> Total Commander (English) Printable version
View previous topic :: View next topic  
Author Message
Alexisback
Junior Member
Junior Member


Joined: 26 Oct 2016
Posts: 8

PostPosted: Sun Jun 18, 2017 3:07 pm    Post subject: Multi-Rename: get File count and rename folder with ? Reply with quote

Hello everyone

is this possible? (With plugins or other) Idea
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)
Back to top
View user's profile Send private message
Dalai
Power Member
Power Member


Joined: 28 Jan 2005
Posts: 5599
Location: Meiningen (Südthüringen)

PostPosted: Sun Jun 18, 2017 4:28 pm    Post subject: Reply with quote

Sure. Get DirSizeCalc plugin, install it, open MRT and use something like
Code:
[N] ([=dirsizecalc.File Count])

See the "[=? Plugin]" button for other plugin fields and stuff.

Regards
Dalai
_________________
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups
Back to top
View user's profile Send private message Send e-mail
Alexisback
Junior Member
Junior Member


Joined: 26 Oct 2016
Posts: 8

PostPosted: Sun Jun 18, 2017 11:34 pm    Post subject: Reply with quote

Hi Dalai

I've already installed this plugin

What I want to do is different Rolling Eyes

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
Back to top
View user's profile Send private message
Stefan2
Power Member
Power Member


Joined: 13 Sep 2007
Posts: 1614
Location: Europa

PostPosted: Mon Jun 19, 2017 3:21 am    Post subject: PowerShell: rename folder with number of files inside Reply with quote

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 ^^^




.


Last edited by Stefan2 on Mon Jun 19, 2017 4:08 am; edited 2 times in total
Back to top
View user's profile Send private message
Alexisback
Junior Member
Junior Member


Joined: 26 Oct 2016
Posts: 8

PostPosted: Mon Jun 19, 2017 4:00 am    Post subject: Re: PowerShell: rename folder with number of files inside Reply with quote

Stefan2 wrote:
You can use your OS scripting tool to accomplish that:

PowerShell
.



Hi Stefan2

I do not know PowerShell

Embarassed Embarassed Confused Rolling Eyes

How to make it work?
Do i have to create a file?

ps:sorry for my English
Back to top
View user's profile Send private message
Dalai
Power Member
Power Member


Joined: 28 Jan 2005
Posts: 5599
Location: Meiningen (Südthüringen)

PostPosted: Mon Jun 19, 2017 7:03 am    Post subject: Reply with quote

Alexisback wrote:
What I want to do is different Rolling Eyes

Well, that depends on the folder's contents.

Quote:
1) counting files within the folder
2) physically rename the folder with count results

I don't see any problem here, i.e. MRT can do that in conjunction with DirSizeCalc plugin.

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).

Quote:
ps:
The link to the plugin is wrong

No, it's not. It's another download source for this plugin, as it is for many other plugins.

Regards
Dalai
_________________
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups
Back to top
View user's profile Send private message Send e-mail
Alexisback
Junior Member
Junior Member


Joined: 26 Oct 2016
Posts: 8

PostPosted: Mon Jun 19, 2017 7:54 am    Post subject: Reply with quote

Dalai wrote:
Alexisback wrote:
What I want to do is different Rolling Eyes


I don't see any problem here, i.e. MRT can do that in conjunction with DirSizeCalc plugin.


Hi Dalai

You're right, I did not read that i have to open MRT (my mistake) Smile
This method works

The problem is this: Rolling Eyes

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
Back to top
View user's profile Send private message
tuska
Power Member
Power Member


Joined: 21 May 2007
Posts: 827

PostPosted: Mon Jun 19, 2017 8:22 am    Post subject: Reply with quote

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


Try https://totalcmd.net/plugring/dirsizecalc.html (https://...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> Total Commander (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group