AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

single vs multi-line select in explorer

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
jamestr



Joined: 05 Apr 2004
Posts: 96
Location: Connecticut USA

PostPosted: Sat May 29, 2004 12:04 am    Post subject: single vs multi-line select in explorer Reply with quote

when i use
send, ^c
to select files in explorer

the crlf EOL codes seems to differ depending on if i selected a single file or multiple files.

single file has no crlf.

a multi file select has crcrlf ,
delimiting the multiple files.

the file append below results in some lines ending with nothing, others end with crcrlf.

FileAppend, %clipboard%`r`n, c:\taggedfiles.txt

How do i handle this?




Code:

a::send a
a & g::
   clipboard =
   send, ^c   
   clipwait, 1
   
   msgbox, 0, ,  %clipboard%, .8
      
   FileAppend, %clipboard%`r`n, c:\taggedfiles.txt   
         
return
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sat May 29, 2004 1:31 am    Post subject: Reply with quote

From the help file: "Each such filename (except the last) is terminated by a carriage return and linefeed (CR+LF), which can be expressed in the script as `r`n."

So if you copy a single file, it won't have a CRLF. But multiple files will have a CRLF between each pair. It was done this way to allow StringSplit and parsing loops to more easily parse the list of files.

Your solution should work okay even if you append multiple selections to the file. It should cause every file to end in a CRLF:
FileAppend, %clipboard%`r`n, c:\taggedfiles.txt

However, because of the way text files are written, you will wind up with an extra CR at the end of every line (`r`r`n). To prevent this, append in binary mode by putting an asterisk in front of the target filename, or use StringReplace to replace `r`n with `n.
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sat May 29, 2004 2:24 am    Post subject: Reply with quote

I think I see the problem now: When you write `r`n to a text file, you wind up with an extra `r (i.e. `r`r`n) because each `n is automatically translated to `r`n when the file is written in text mode. I've updated the clipboard section of the help file to explain how to deal with this:

To write the filenames on the clipboard to a text file via FileAppend, first replace `r`n with `n as in this example:

StringReplace, clipboard, clipboard, `r`n, `n
FileAppend, %clipboard%`n, C:\My File.txt
Back to top
View user's profile Send private message Send e-mail
jamestr



Joined: 05 Apr 2004
Posts: 96
Location: Connecticut USA

PostPosted: Sat May 29, 2004 11:31 pm    Post subject: Reply with quote

ah ha.

I had erroneously assumed that the ^c command had inserted the extra cr. (crcrlf).

thats why i posted in the bug forum.

thanks for the explanation.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sat May 29, 2004 11:33 pm    Post subject: Reply with quote

Oops, I forgot the "all" at the end, so please revise it to use this:
StringReplace, clipboard, clipboard, `r`n, `n, All
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group