Can the inputfolder command return Short Path Names

Discuss and share scripts and script files...
Post Reply
Lare2
Posts: 65
Joined: 18 Sep 2006 08:29

Can the inputfolder command return Short Path Names

Post by Lare2 » 29 Sep 2009 21:41

Is there a way to make the inputfolder command return the Short Path Names of a selected folder instead of the full path name.

admin
Site Admin
Posts: 49770
Joined: 22 May 2004 16:48
Location: Cologne, Win 8.1, Win 10
Contact:

Re: Can the inputfolder command return Short Path Names

Post by admin » 29 Sep 2009 22:11

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
FAQ | XY News RSS | XY Twitter | Stay home! 🎸 Or wear a mask! 😷

Lare2
Posts: 65
Joined: 18 Sep 2006 08:29

Re: Can the inputfolder command return Short Path Names

Post by Lare2 » 29 Sep 2009 22:50

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

admin
Site Admin
Posts: 49770
Joined: 22 May 2004 16:48
Location: Cologne, Win 8.1, Win 10
Contact:

Re: Can the inputfolder command return Short Path Names

Post by admin » 29 Sep 2009 22:54

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:
FAQ | XY News RSS | XY Twitter | Stay home! 🎸 Or wear a mask! 😷

TheQwerty
Posts: 4353
Joined: 03 Aug 2007 22:30

Re: Can the inputfolder command return Short Path Names

Post by TheQwerty » 29 Sep 2009 22:55

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.

admin
Site Admin
Posts: 49770
Joined: 22 May 2004 16:48
Location: Cologne, Win 8.1, Win 10
Contact:

Re: Can the inputfolder command return Short Path Names

Post by admin » 29 Sep 2009 23:00

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);
FAQ | XY News RSS | XY Twitter | Stay home! 🎸 Or wear a mask! 😷

Lare2
Posts: 65
Joined: 18 Sep 2006 08:29

Re: Can the inputfolder command return Short Path Names

Post by Lare2 » 29 Sep 2009 23:18

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.

Post Reply