Classic Shell
http://classicshell.net/forum/

Question| How to send folders/files to a program by button?
http://classicshell.net/forum/viewtopic.php?f=8&t=7623
Page 1 of 1

Author:  Stamimail [ Fri May 19, 2017 8:05 am ]
Post subject:  Question| How to send folders/files to a program by button?

I wanted to send folders/files selected to Renamer by Classic Explorer button
http://www.den4b.com/forum/viewtopic.php?id=2312

Author:  Gaurav [ Sat May 20, 2017 12:28 pm ]
Post subject:  Re: Question| How to send folders/files to a program by butt

You can use the following placeholders in a Custom button's Command or Link field:

◦%1 is the path of the current folder. Keep in mind that if the current folder is a root of a drive it will end with a backslash (like C:\)

◦%2 is the path of the selected file (only when a single file is selected). Does not work for multiple selected files

◦%3 is a name of a temporary text file that contains all selected files. Each line in the text file contains one file with its full path. Meaning you will have to first output multiple selected files to a temporary text file in %tmp% for example.

◦%4 is the same as %3, but the file is in Unicode (UTF16) format. The file contains no byte order mark. %3 and %4 can't both be used by the same command

Note to developers: When %3 or %4 is used, it is the responsibility of the command to delete the temporary file when it finishes. Otherwise the temp file will be left behind and waste disk space. Also if the command is a console application or a batch file it will be launched in silent mode with no console window


◦%5 is a name of a temporary text file, which can be used to return a command back to Classic Explorer. If the first 2 bytes of the file are 255 and 254, the file is treated as Unicode. Only one command can be used at a time. The command can be:
◾open <folder name> - causes Explorer to navigate to the given folder
◾select <list of file names> - selects the given files, deselects the rest. The file names must be separated by a tab or a newline character. The files should not contain a path. If they do, the path will be ignored

◾refresh - refreshes Explorer
◦Note to developers: commands using %5 will run in silent mode (like commands using %3 or %4) but also Explorer will wait for the process to finish. The process must finish as quickly as possible, because Explorer will be frozen during the execution of the command

****************************************************************************
An example:

Copy selected files to the parent folder

Create a batch file called C:\CopyParent.bat:
set list=%1
set list=%list:"=%
for /F "delims=" %%i in (%list%) do copy /Y "%%i" ..
del %1

Use this command: C:\CopyParent.bat "%3". %3 will be replaced by a text file containing the full names of all selected files. The batch file will read each line of that text file, and copy each of the selected files to the parent folder. At the end the batch file deletes the initial temp file. The first two set commands remove the quotes from the %1 parameter.

Author:  Stamimail [ Sun Jun 04, 2017 5:10 am ]
Post subject:  Re: Question| How to send folders/files to a program by butt

I guess I need to use %4 in my case.
Unfortunately I don't have enough experience with batch scripting.
Can I get help with this?
How to make correctly the batch file for sending selected folders&files to a program?
thanks in advance.

Author:  Stamimail [ Tue Jun 13, 2017 5:03 am ]
Post subject:  Re: Question| How to send folders/files to a program by butt

It doesn't work for me for some reason.
Which version of Classic shell I need for that?

Author:  Stamimail [ Wed Aug 09, 2017 2:43 pm ]
Post subject:  Re: Question| How to send folders/files to a program by butt

I got some help. The following command works for me:
Code:
"C:\Program Files (x86)\ReNamer\ReNamer.exe" /list %3

But I have 2 probelms:
1. Using this command, how do I delete the .tmp file in %temp%?
2. Assume I select the 4 first files of mp3 files folder:

1.mp3
2.mp3
3.mp3
4.mp3

5.mp3
6.mp3
7.mp3

and then I click the "custom button" in Classic Bar - It sends the list to Renamer in this way:

4.mp3
1.mp3
2.mp3
3.mp3

It's not the desired behaviour. The user is expecting to have the order of the files in the list in the same order of the files in the folder, no matter what the order of the selection was (no matter what file selected first/last).

Author:  Gaurav [ Thu Aug 10, 2017 6:09 am ]
Post subject:  Re: Question| How to send folders/files to a program by butt

You can use a batch file to delete the .tmp file and include the Rename command in that batch file.

The file order issue is buggy Windows Explorer behavior I think (of the File Pane). You could try selecting it differently using the mouse or using the keyboard.

Author:  Stamimail [ Thu Aug 10, 2017 7:46 am ]
Post subject:  Re: Question| How to send folders/files to a program by butt

Quote:
You can use a batch file to delete the .tmp file and include the Rename command in that batch file.
I have already understood it, but I haven't the scripting knowledge. Do you know what is the code I need to put in the bat file? thanks.
Quote:
The file order issue is buggy Windows Explorer behavior I think (of the File Pane).
Is this something can be fixed by Classic Shell? (Feature Request)

Page 1 of 1 All times are UTC - 8 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/