 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jamestr
Joined: 05 Apr 2004 Posts: 96 Location: Connecticut USA
|
Posted: Sat May 29, 2004 12:04 am Post subject: single vs multi-line select in explorer |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10463
|
Posted: Sat May 29, 2004 1:31 am Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10463
|
Posted: Sat May 29, 2004 2:24 am Post subject: |
|
|
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 |
|
 |
jamestr
Joined: 05 Apr 2004 Posts: 96 Location: Connecticut USA
|
Posted: Sat May 29, 2004 11:31 pm Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10463
|
Posted: Sat May 29, 2004 11:33 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|