Classic Shell development was stopped in December 2017. For now the forum remains online as reference, but is read-only. Registration of new users is disabled.
It is currently Sun Oct 19, 2025 2:07 pm

All times are UTC - 8 hours [ DST ]


Forum rules


Before posting a bug report or a feature request, search the forum for an older post on the same topic. If you are reporting a crash, try capturing a crash dump. You can find instructions here: How to capture crash dumps



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Feb 16, 2014 11:47 am 
Offline

Joined: Sun Feb 16, 2014 10:57 am
Posts: 2
I've written a script to add timestamps to filenames. It gets run by a custom button in Classic Explorer.

I can select one or more files in Explorer, hit the button, it passes the list of selected files (placeholder %3) to my script, the script does its thing, and it passes back a list of the new filenames in the to-select file (placeholder %5). The idea being, the same files are still selected in Explorer afterwards as before, only now they have new names.

But the selection part doesn't work. Specifically, it seems Explorer FIRST attempts to do the selecting (based on the "files to select" temporary file named in %5), and THEN refreshes its list of files. It ought to do this the other way around.

Similarly, if I write a script to create a file and select it, the selection part fails for the same reason.

Example code to illustrate this:
Code:
rem ------------------------------------------------------------
rem newscript3.bat thundt rev 1 16-Feb-14
rem ------------------------------------------------------------
rem This creates a bogus file and puts its name into the selection file.
rem Expected result: new file foo.txt, selected by Explorer.
rem Actual result: FIRST time, the file appears but is not selected
rem SECOND time, file is selected. Hmm!
rem Conclusion: CE does not refresh its directory list until AFTER doing the selecting.
rem This breaks selection feature when running scripts that add or rename files.
rem ------------------------------------------------------------

rem Command line in CE
rem %USERPROFILE%\tmp\newscript3.bat -i %3 -s %5

rem Create some new bogus file
echo foobar> foo.txt

rem Stick its name in the selection file
echo select>%4
echo foo.txt>>%4


(The "-i" and "-s" are there because it's what I use in my renaming script. The parameters do get passed correctly.)

Less stripped-down version with more instrumentation for debugging -- you can use it to confirm the parameters get passed correctly:
Code:
rem (newscript2.bat)
set mypath=%~d0%~p0
set F=%mypath%\newscript2.log
date /t >> %F%
time /t >> %F%
echo got param 1 = %1 >> %F%
echo got param 2 = %2 >> %F%
echo got param 3 = %3 >> %F%
echo got param 4 = %4 >> %F%

echo Contents of %2 >> %F%
echo ---- >> %F%
type %2 >> %F%
echo ---- >> %F%

rem now try to run it in perl
rem C:\App\Perl\bin\perl.exe c:\winbin\fixdatecode.pl -i %mypath%\in.txt -s %mypath%\select.txt
REM C:\App\Perl\bin\perl.exe c:\winbin\fixdatecode.pl -i %2 -s %4

rem Attempt to debug the selecting-on-completion part.
rem We ignore the input file entirely.

rem Create some new bogus file
echo foobar> foo.txt

rem Stick its name in the selection file
echo select>%4
echo foo.txt>>%4

echo Contents of %4 >> %F%
echo ---- >> %F%
type %4 >> %F%
echo ---- >> %F%
call hexdump %4>>%F%
echo ---- >> %F%


(This will complain you don't have the 'hexdump' script I'm using. But ought to work, otherwise. I was trying to see if Perl was doing anything funny with the file; it was not. Straight Windows text file, just like the examples in the help.)

Sorry if this has been covered before; I wasn't able to find it.
Thanks for any help.


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 17, 2014 8:54 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 02, 2013 11:38 pm
Posts: 5333
I don't think this can be fixed. Explorer runs the refresh in a background thread. Even if I initiate a refresh, it won't finish (or even start) for some time. There is no way I can block the UI thread while waiting for it to finish. It can potentially take a long time.


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 01, 2014 12:01 pm 
Offline

Joined: Sun Feb 16, 2014 10:57 am
Posts: 2
Aha, thanks, appreciate your reply. Kind of a bummer but there's only so much you can control, right?

Thanks again


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 84 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group, Almsamim WYSIWYG Classic Shell © 2010-2016, Ivo Beltchev.
All right reserved.