Page 1 of 1

Can the inputfolder command return Short Path Names

Posted: 29 Sep 2009 21:41
by Lare2
Is there a way to make the inputfolder command return the Short Path Names of a selected folder instead of the full path name.

Re: Can the inputfolder command return Short Path Names

Posted: 29 Sep 2009 22:11
by admin
Lare2 wrote:Is there a way to make the inputfolder command return the Short Path Names of a selected folder instead of the full path name.
No, and I'd rather give you an extra function to convert long to short names. But only if you tell my for what you need it. :P

Re: Can the inputfolder command return Short Path Names

Posted: 29 Sep 2009 22:50
by Lare2
I probably don't need it so please take a look at the code below. (which TheQwerty helped me put together)

Code: Select all

/*------------------------------------------------------------------------------
This script is the default entry point.
------------------------------------------------------------------------------*/
"Main"
   Sub("_setPaths"); //Declare and set the global vars.
   Load("*", "_clipboard;_curItem"); //Load the desired menu, which can now use the global vars.

/*------------------------------------------------------------------------------
This script sets the global variables to be used by other WGET SCRIPTS.
------------------------------------------------------------------------------*/
"_setPaths"
   Global $wget, $target;
   $wget = <xypath>\wget\wget; // WGET EXE PATH
   $target = C:\DOCUME~1\Carlos\Desktop\Downloads; // TARGET DOWNLOAD FOLDER

/*------------------------------------------------------------------------------
01   D O W N L O A D   F R O M   C L I P B O A R D

This script will download the URL on the clipboard
WGET ARGUMENTS = run """cmd"" /k ""[WGET PATH]"" --directory-prefix=[TARGET PATH] [URL]"
------------------------------------------------------------------------------*/

"Download File On Clipboard : _clipboard"
   Global $wget, $target;

   msg Would you like to download the following <br><br> <clipboard>, 1; // CONFIRM URL TO DOWNLOAD WITH MESSAGE BOX

   run """cmd"" /k ""$wget"" -c --directory-prefix=$target <clipboard>"; // WGET COMMAND ARGUMENTS

/*------------------------------------------------------------------------------
02   D O W N L O A D   F R O M  F I L E

This script will attempt to download a series of links from a TXT file.
------------------------------------------------------------------------------*/

"Download From Links On Selected File : _curItem"
   Global $wget, $target;

   $linktxt = readfile(<curitem>);
   msg The following files will be downloaded <br><br>$linktxt, 1;

   run """cmd"" /k ""$wget"" -c --directory-prefix=$target --input-file=<curitem>";
I want to change the following part

Code: Select all

$target = C:\DOCUME~1\Carlos\Desktop\Downloads; // TARGET DOWNLOAD FOLDER
with something like the following

Code: Select all

inputfolder $target, c:\ , Select the target folder;
When i tried the above, WGET (cmd program) truncates the path. If I select Desktop from the dialog box then WGET truncates the path to C:\Documents instead of C:\Documents and Settings\user\Desktop\

My complete lack of knowledge about scripting tells me that there should be a way to do this without my request. :D

Re: Can the inputfolder command return Short Path Names

Posted: 29 Sep 2009 22:54
by admin
Try to quote your $target in the run command...

Generally: Are quotes very expensive where you come from? Your code really could need some more... :wink:

Re: Can the inputfolder command return Short Path Names

Posted: 29 Sep 2009 22:55
by TheQwerty
Lare2 wrote:When i tried the above, WGET (cmd program) truncates the path. If I select Desktop from the dialog box then WGET truncates the path to C:\Documents instead of C:\Documents and Settings\user\Desktop\
It's not so much that you need the short name as you need to quote the path since it contains spaces.

Try this:

Code: Select all

/*------------------------------------------------------------------------------
This script is the default entry point.
------------------------------------------------------------------------------*/
"Main"
   Sub("_setPaths"); //Declare and set the global vars.
   Load("*", "_clipboard;_curItem"); //Load the desired menu, which can now use the global vars.

/*------------------------------------------------------------------------------
This script sets the global variables to be used by other WGET SCRIPTS.
------------------------------------------------------------------------------*/
"_setPaths"
   Global $wget, $target;
   $wget = "<xypath>\wget\wget"; // WGET EXE PATH
   $target = "C:\DOCUME~1\Carlos\Desktop\Downloads"; // TARGET DOWNLOAD FOLDER

/*------------------------------------------------------------------------------
01   D O W N L O A D   F R O M   C L I P B O A R D

This script will download the URL on the clipboard
WGET ARGUMENTS = run """cmd"" /k ""[WGET PATH]"" --directory-prefix=[TARGET PATH] [URL]"
------------------------------------------------------------------------------*/

"Download File On Clipboard : _clipboard"
   Global $wget, $target;

   msg "Would you like to download the following <br><br> <clipboard>", 1; // CONFIRM URL TO DOWNLOAD WITH MESSAGE BOX

   run """cmd"" /k ""$wget"" -c --directory-prefix=""$target"" ""<clipboard>"""; // WGET COMMAND ARGUMENTS

/*------------------------------------------------------------------------------
02   D O W N L O A D   F R O M  F I L E

This script will attempt to download a series of links from a TXT file.
------------------------------------------------------------------------------*/

"Download From Links On Selected File : _curItem"
   Global $wget, $target;

   $linktxt = readfile("<curitem>");
   msg "The following files will be downloaded <br><br>$linktxt", 1;

   run """cmd"" /k ""$wget"" -c --directory-prefix=""$target"" --input-file=""<curitem>""";
EDIT: Don, I will admit I'd like to see SplitPath and Rel2Abs/Abs2Rel functions.

Re: Can the inputfolder command return Short Path Names

Posted: 29 Sep 2009 23:00
by admin
admin wrote:Try to quote your $target in the run command...

Generally: Are quotes very expensive where you come from? Your code really could need some more... :wink:
I'd simply do this:

Code: Select all

inputfolder $target, "c:\" , "Select the target folder";
//put the quotes into the var
$target = quote($target);

Re: Can the inputfolder command return Short Path Names

Posted: 29 Sep 2009 23:18
by Lare2
Amazing what someone can learn by asking. :)

As a person that learns mainly by example, I really apreciate you for taking the time to respond.

Thank you again guys for the help.