counter in variable location in filename

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
beb
Senior Member
Senior Member
Posts: 435
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: counter in variable location in filename

Post by *beb »

2Rekumbens
It's not enough just to drag the .js file on the panel.
You also need to edit the button and add the required parameters as described in Fla$her's .js file header.

Taking into account your screenshots, the button could be like this:

Code: Select all

TOTALCMD#BAR#DATA
"c:\Munka\ex librisek\id\p.js"
"%P" tif 9600
C:\Windows\System32\WScript.exe,3
p
c:\Munka\ex librisek\id\
0
-1
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10
Fla$her
Power Member
Power Member
Posts: 2318
Joined: 2020-01-18, 04:03 UTC

Re: counter in variable location in filename

Post by *Fla$her »

2Rekumbens
You haven't answered my question:
Fla$her wrote: 2024-01-07, 19:49 UTC What parameters did you specify?
Fla$her wrote: 2024-01-07, 14:58 UTC Save to ANSI, drag to the toolbar, and specify the suggested parameters in the second button field.
Overquoting is evil! 👎
User avatar
beb
Senior Member
Senior Member
Posts: 435
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: counter in variable location in filename

Post by *beb »

2Rekumbens
Could you be so kind as to give it another try to run the PowerShell script as well?

Here's the modified button (for p.ps1 as you named it, to run it from the active panel)

Code: Select all

TOTALCMD#BAR#DATA
powershell -executionpolicy bypass .\p.ps1

WCMICONS.DLL
PowerShell_inventoryRecount

0
-1
And here's the script (modified a bit regarding your screenshot: removed literal source folder definition; added a part to display the renumbered items):
p.ps1 (as you named it)

Code: Select all

$id  = 62000
$tif = Get-ChildItem -path $pwd -filter *.tif -recurse|Sort-Object -property FullName
$tif | Where-Object {$_.Name -match '\d{5}' -and $_.Name -notmatch '\d{6}'}|Rename-Item -NewName {$_.Name -replace "\d{5}",$script:id++} -PassThru|Foreach-Object {Write-Host $_.Name -f Yellow}
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10
sa16
Senior Member
Senior Member
Posts: 217
Joined: 2021-09-10, 07:15 UTC

Re: counter in variable location in filename

Post by *sa16 »

2Rekumbens
If sorting by old name is not needed, then one point is enough:
1)
Rename mask: file name [C62000][N]
Search for: (\d{5})(.*)(\d{5})(.*)
Replace with: $2$1$4
Post Reply