What does $P expand to ...

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

Post Reply
Gary M. Mugford
Bronze Member
Bronze Member
Posts: 145
Joined: 2009 Oct 14, 00:54
Location: Brampton ON Canada

What does $P expand to ...

Post by Gary M. Mugford » 2018 Oct 01, 20:19

I am using v2.5. So, put on your OLD version thinking caps.

I have a batchfile that I'm trying to use with Ant Renamer to work on a folder's worth of files. A BIIIIG FOLDER's worth of files. I want to click at random on any file in a random folder, and have the full command work. It is this:

Code: Select all

> E:\apps\Utilities\Ant Renamer\Renamer.exe -b F:\Shez\gmRenBatch01.arb -afr $P -g -x
Crickets when I click on the icon in the toolbar or through the User Commands menu. Nothing happens, although I DO sense Ant Renamer flashing by.

Now, IF I highlight something less than 254 files (really not sure WHAT the limit is) and click the icon I have connected to this user command, everything works as I want:

Code: Select all

> E:\apps\Utilities\Ant Renamer\Renamer.exe -b F:\Shez\gmRenBatch01.arb -af $S -g -x
If I am clicking on a random file in K:\Source_Research and want the all the files in that HUUUUUUUUGE folder to run through the Ant Renamer software, WHAT does $P expand to? Is it K:\Source_Research? The example from the Ant Renamer help looks like this:
  • Here is the list of supported parameters:

    -b FileName.arb : Loads the batch file called FileName.arb
    -g : Launches the renaming process after files have been added and batch file loaded
    -x : Quits the program after the renaming process
    -a : Change the file add mode, based on the letters following the "-a" parameter:
    f : Add files from filenames/paths that follow
    F : Add folders that follow, or contained in folders, see examples
    r : Recursive addition of folders' contents
    The filenames and paths can be relative or absolute, and they can contain wildcards (* and ?).
    Here are some examples:
    Renamer.exe -b d:\test.arb -af c:\data\*.* -g -x
    This will load the batch file specified, add all files contained in c:\data folder, start renaming and then exit

    Renamer.exe -af c:\data
    This will add the file called c:\data
    Renamer.exe -afr c:\data
    This will add the file called c:\data. If it is a folder, it will add the files that it contains (recursive search)
    Renamer.exe -aF c:\data
    This will add the "data" folder
    Renamer.exe -aF c:\data\*.*
    You can combine several paths/filenames, use masks, and use different "-a" parameters in one command line
I can manually do a couple hundred files at a time and it's pretty quick. What I WANT to do, is click in the folder, click on the icon and go have supper.

Thanks in advance for any help, GM

User avatar
pschroeter
Silver Member
Silver Member
Posts: 263
Joined: 2007 Jan 27, 00:46

Re: What does $P expand to ...

Post by pschroeter » 2018 Oct 02, 03:13

I think you posted in the wrong forum. This is the forum for xplorer2.

User avatar
nikos
Site Admin
Site Admin
Posts: 14668
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: What does $P expand to ...

Post by nikos » 2018 Oct 02, 04:22

$P is the PATH of the selected file (without filename). $F is the fullpath+name. $S is all selected files (without paths). FOr more information see the full list here https://www.zabkat.com/x2h_7.htm#dos_tok

Gary M. Mugford
Bronze Member
Bronze Member
Posts: 145
Joined: 2009 Oct 14, 00:54
Location: Brampton ON Canada

Re: What does $P expand to ...

Post by Gary M. Mugford » 2018 Oct 04, 06:23

That being the case Nikos, then the expanded user command should expand fully to the correct command-line for Ant Renamer. I dl'd the code and looked to maybe rewrite the code and collect MORE files than the limit currently imposed, but it has a ton of specialized adaptations of components I have already and the naming conflicts put the kibosh on that. Since I DO have the syntax correct, I guess I have one of two ways to go. [1] keep running it after selecting a couple hundred files in x2 (yes, I DO have the correct forum PS) and then clicking on the command with JUST the -af switch, or [2] do a batch file that continually runs against a single folder. The latter DOES solve on-going issues. Now, the large TREE of folders I'd like it to recurse through? Not so much. There's the Sweep utility that might let me run a repeated batchfile than selects all and then runs Ant Renamer with my batch against it. That might resolve problem with the existing folder tree. Hmmmm, sure wish the path variable worked in the user command. Oh well, life happens.

Thanks for the confirmation Nikos. GM

User avatar
nikos
Site Admin
Site Admin
Posts: 14668
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: What does $P expand to ...

Post by nikos » 2018 Oct 04, 07:46

there is a limit to what a command line will take, so if you add too many names (characters) then it will burst. Some programs to work around this basic limitation, allow reading filenames from a file, and that you can do in xplorer2 using the "secret" token (requested by the lost kilmatead):
User command token $> for the odd (sic) need to pass all selected items through a list file. This is equivalent to $A token but the paths are saved to the file %TEMP%\x2tmpList.txt, then this file is used as the $> argument. Useful for situations where you need to pass too many files to some external tool.

Gary M. Mugford
Bronze Member
Bronze Member
Posts: 145
Joined: 2009 Oct 14, 00:54
Location: Brampton ON Canada

Re: What does $P expand to ...

Post by Gary M. Mugford » 2018 Oct 09, 17:03

Nikos,

I modified my code to use the $> as a trial with a sub-folder relatively deep into the rat's nest of this tree. Tried it with clicking in the folder but not selecting a file, selecting a file and finally selecting all files (there NOT being a sub-folder in it). In each case, ant renamer flashed by without doing anything. This was the 'new' code, replacing $P with $>

Code: Select all

> E:\apps\Utilities\Ant Renamer\Renamer.exe -b F:\Shez\gmRenBatch01.arb -afr $P -g -x
now

Code: Select all

> E:\apps\Utilities\Ant Renamer\Renamer.exe -b F:\Shez\gmRenBatch01.arb -afr $> -g -x
With those two failing on a single folder with a few files, I applied the original, which STILL works with less than 255 selected files ...

Code: Select all

> E:\apps\Utilities\Ant Renamer\Renamer.exe -b F:\Shez\gmRenBatch01.arb -af $S -g -x
The ORIGINAL COMMAND worked and fixed all the file names as I desired them. Thus, I believe path length is NOT involved in this issue. The ant renamer help file clearly indicates that the -afr command IS FOR HANDLING FOLDERS including sub-folders. And just as clearly, this doesn't work as a user command in x2. And understand this is about a four-way pass through the file name, changing case, eliminating extraneous information, clearing out old syntax in the naming and finally adding the date in YYYMMDD format to the name for sorting purposes. Yeah, it's a bother to re-organize after decades of one organizational method, but I've outlived the limits of the original scheme. So it's ME causing ME my problem.

Unfortunately, this is going to be either a fix from the ant renamer guy (who, unlike you, hasn't updated in a few years), or I accept manually doing it while listening to a podcast. Or two. Or a dozen. My fault.

Thanks for trying to help. GM

User avatar
nikos
Site Admin
Site Admin
Posts: 14668
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: What does $P expand to ...

Post by nikos » 2018 Oct 10, 03:33

you cannot simply switch $P for $> and expect it to work :)
you need to see in this ant's documentation if there's a special command line switch that allows use of listing files as inputs to the program. Not all programs support such advanced inputs

User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1168
Joined: 2005 Oct 16, 19:09

Re: What does $P expand to ...

Post by FrizzleFry » 2018 Oct 10, 12:53

Since the path to the executable has a space you should enclose it in quotes

"E:\apps\Utilities\Ant Renamer\Renamer.exe"

The $> token puts the full paths of selected files into a temp file and sends that as a parameter so the program or batch file would have to be able to deal with a file containing a list of files. It's similar to the $A token but used to handle situations where many files are selected and the size of the command line buffer might be exceeded.

$P sends the parent folder of the selected file(s) in the active pane
$S sends the filenames (with no path) of the selected file(s) in the active pane

Post Reply