AutoHotkey Community

It is currently May 26th, 2012, 12:02 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: September 5th, 2008, 12:42 pm 
Offline

Joined: September 2nd, 2007, 1:56 am
Posts: 15
Location: urban india = hell
I want to run 7zip on a selected archive in windows explorer via a keyboard shortcut.

I am trying to split the path for the selected file/folder such that I can surround the path components which have spaces in them with quotes - so 7zip can work.

For eg,
C:\Documents and Settings\Administrator\Desktop\converber.zip

Here, I need to parse and then change the relevant part to ---

C:\"Documents and Settings"\Administrator\Desktop\converber.zip

The code I wrote is below, but I am getting stuck because I cant add the \ to the regenerated string?

Sorry if the mistake is stupid, but I cant solve it!

Please help!! :)

Code:
   BlockInput, Mousemove  ;Block mouse movement
   clipboard=
   send, ^c
   ClipWait, 0.5
   filename=%clipboard%
            clipboard := oldclip
   BlockInput, MousemoveOff ;Enable mouse movement   
Loop, Parse, filename, '\
{
IfInString, A_LoopField, %A_Space%
{
dospath := %dospath%"%A_LoopField%"
dospath := dospath\ ;gives error!

}
else
{
dospath := %dospath%%A_LoopField%"\
}
}
Length := StrLen(dospath) -1
dospath := SubStr(dospath, 1 , Length) ; to remove final \
   

_________________
no fate but what we make


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 5th, 2008, 1:10 pm 
yogi wrote:
I want to run 7zip on a selected archive in windows explorer via a keyboard shortcut.

I am trying to split the path for the selected file/folder such that I can surround the path components which have spaces in them with quotes - so 7zip can work.

For eg,
C:\Documents and Settings\Administrator\Desktop\converber.zip

Here, I need to parse and then change the relevant part to ---

C:"Documents and Settings"\Administrator\Desktop\converber.zip

The code I wrote is below, but I am getting stuck because I cant add the \ to the regenerated string?

Sorry if the mistake is stupid, but I cant solve it!

Please help!! :)


First to get the components of a path\filename use SplitPath. It is much easier to use and there will be no mistakes (uses system calls to parse the path\file). BTW it can also parse url's.

Second, unless something is very strange with your run 7zip command, 7zip should be very happy with something like:
Code:
run %comspec% /k "C:\Program Files\Utils\archivers\7za.exe" l "c:\My Documents\DownLoads\RegDllView v1.15.zip"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2008, 2:09 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Simple solution would be to convert filepath to 8.3 format

Code:
Clipboard := A_AhkPath
Loop %Clipboard%
  File := A_LoopFileShortPath

MsgBox, %File% 


:)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 5th, 2008, 3:44 pm 
Anonymous wrote:
Second, unless something is very strange with your run 7zip command, 7zip should be very happy with something like:
Code:
run %comspec% /k "C:\Program Files\Utils\archivers\7za.exe" l "c:\My Documents\DownLoads\RegDllView v1.15.zip"


Ah, I did not think of the obvious solution of surrounding the entire path with quotes! Thank you for telling me :)

But I still do not understand how does one concatenate strings in ahk? and if there are any special chars, then how do I use escape seqeuences to include them.

Currently, the only thing I need is to surround an entire string with double quotes, how do I do that?


Report this post
Top
  
Reply with quote  
PostPosted: September 5th, 2008, 3:52 pm 
Offline

Joined: September 2nd, 2007, 1:56 am
Posts: 15
Location: urban india = hell
Anonymous wrote:
Currently, the only thing I need is to surround an entire string with double quotes, how do I do that?


oops I posted the above comment as guest. Anyway I figured it out,
target = "%filename%"

_________________
no fate but what we make


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey and 18 guests


You can post new topics in this forum
You can 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:
Powered by phpBB® Forum Software © phpBB Group