Jump to content
Macro Express Forums
burt

Specific Macro Question

Recommended Posts

I am a new Macro Express user and I am trying to make a macro which does the following:

 

I have a long list of files say from 0001.txt - 1000.txt

I want to make a copy of a certain selected file say 0234.txt with copy/paste and jump back to the file I just selected before copying. All in the same directory.

 

So when I have file 0234.txt selected and I do copy/paste the file is named "Copy of 0234.txt"

After that I want to jump back and select file 0234.txt automaticly without scrolling back.

 

This can be done manual to type in 0234 in explorer and the file will be selected (Windows XP).

 

 

But how can I do this in a macro?

 

I did the following:

 

File 0234.txt is selected in explorer.

 

TEXTTYPE:<F2>

TEXTTYPE:<CONTROL>c

TEXTTYPE:<ESC>

CLIPST2:0:C:\Temp\clip.txt

 

;now the filename is copied to the clipboard and saved to a file named clip.txt (i'd rather do this in memory, but yet I don't know how to do this)

 

TEXTTYPE:<CONTROL>c

TEXTTYPE:<CONTROL>v

 

; now the selected file is copied to "Copy of 02345.txt"

 

 

From here it doesn't work as I would like to.

I read the filename back to the clipboard and what shuold happen is that the characters from the clipboard must be typed in sequence with a slight delay, because when I do just paste the filename it doesn't gets selected.

 

CLIPF2:2:C:\Temp\clip.txt

SPKEY:500

TEXTTYPE:<CONTROL>v

 

I ment here tot read the file name back into the clipboard, put in 500ms delay in the pasted text what's typed in explorer.

But this doesn't work and file 0234.txt isn't selected.

 

Any experienced user can give me a hint?

How can I manage that the filename from the clipboard is typed in just as I sould do it manually.

 

Thanks, and best regards to all,

Burt

Share this post


Link to post
Share on other sites

There's no harm in using a text file for memory though you can do your operation without. Assumed that the filepath is always c:\temp. If not then other steps need to be added to create the filepath, say %T2%.

 

Do as you are doing copying the filename to the clipboard

Variable set string %T1% from the clipboard

Files/Folders Copy...

Files/Path Name: c:\temp\%T1%

New Name: c:\temp\Copy of %T1%

 

The cursor/selection in Explorer should not change

Share this post


Link to post
Share on other sites

Thanks for the reply.

Played with your hints, but I couldn't get it to work.

 

I managed to get it working, but your way would be better because there's no jumping around of the selected file.

 

With your method nothing were copied, I guess because the filenames doesn't include extensions visible over here.

 

But what I found was the "Clipboard type text" function. The whole macro is like this.

 

Text Type: <F2>

Text Type: <CONTROL>c

Text Type: <ESC>

Variable Set String %T1% from Clipboard

Text Type: <CONTROL>c

Text Type: <CONTROL>v

Variable Modify String: Save %T1% to Clipboard

Clipboard Type Text

 

Buffering the filename to a file didn't work because after the last character a return was given, so after typing out the last character in the end of the macro an Enter was given so the file was launched!

 

Although it does everything I need, what you suggested would be a better solution.

But I can't get that to work.

 

Text Type: <F2>

Text Type: <CONTROL>c

Text Type: <ESC>

Variable Set String %T1% from Clipboard

 

Everything ok until here, but

Copy File or Files: "%T1%"

-----------------------------------------------

With file extensions visible in explorer:

Files(s) Path/Name:

c:\%T1%

New Name:

d:\%T1%

File copied ok

-----------------------------------------------

 

With file extensions NOT visible in explorer:

Nothing copied. Rather logical

 

But how into the working directory because it must work in every directory?

-----------------------------------------------

File extensions visible in explorer:

Files(s) Path/Name:

%T1%

New Name:

%T1%

Nothing copied.

-----------------------------------------------

 

Is there a way to copy a filename with extension to the clipboard, and how do I get this to work in all directories? How do I readout the filepath from the selected file?

 

 

Anyway, your help with introducing me to variables was great!

 

Thanks, Burt

Share this post


Link to post
Share on other sites

My method definitely does work. I was assuming you are showing the full file name and extension in Explorer. Not showing the extension is going to make life difficult. When I'm doing file operations I ALWAYS have the full name and extension visible to be sure I have the right file, but that's personal preference.

 

If you want this to work in Explorer with no file extension and in any folder, I'll leave that to someone else to solve!

 

I don't use Explorer, ever. After all these years they still do not have an icon for creating a new folder. I use old PowerDesk which will also copy the full name and path of a file to the clipboard, making this sort of thing a breeze.

Share this post


Link to post
Share on other sites

Ok, thanks,

 

But even if the full filepath would be on the clipboard i.e. "c:\data\0234.txt",

"Copy of %T1%" would result in the filename: "Copy of c:\data\0234.txt", which is an impossible filename.

And changing "Copy of %T1%" in "%T1%_Copy" would end in "c:\data\0234.txt_copy" so now the extension gets corrupted.

 

So I don't understand how you manage this with copying files in the same directory.

With different directories there is no problem.

This is a headbreaker for me as a new (4 days) Macro Express user.

Share this post


Link to post
Share on other sites

Hello Burt!

 

Question for you: How do you know which files you want to make a copy of? Do you know ahead of time before opening Windows Explorer? Or is copying files done on-the-fly?

Share this post


Link to post
Share on other sites

Well the situation is I am a photographer and I sometimes make 200 or more photo's a day.

So after transferring my photo's to a harddisk folder I have a long list of files named DSCN2004091215 and 199 others named automaticly by the camera using a sort of filestamp.

After that I look at them with the arrow down keys and when I see a photo which I want to save I do copy/paste. So after looking at all the photo's I have a few named copy of etc. which I will handle further.

 

But It is very annoying to scroll back in the list every time I have copied a photo because all the filenames look so similar . . .

 

So that is the situation. I know what to copy after I see the file. And it's always the selected file.

(And I do this in ACDsee but I didn't mention that not to make things even more complicated)

Share this post


Link to post
Share on other sites

Noggin wrote:

I don't use Explorer, ever. After all these years they still do not have an icon for creating a new folder. I use old PowerDesk which will also copy the full name and path of a file to the clipboard, making this sort of thing a breeze.

FYI, I use a product called Directory Opus, whose users generally have the same sort of contempt for Powerdesk as you do for Explorer (BTW, I am nothing whatever to do with the makers of DO).

 

http://www.gpsoft.com.au/

Share this post


Link to post
Share on other sites

Paul

Re Explorer shells. I use both PowerDesk and Opus. PowerDesk is generally better for what I need but getting a bit old for XP. The split screen in PD is a bit more convenient for some operations I do. I use Opus for run-of-the-mill work. Hooray, it can be customized with make a new folder icon! It's quite unbelievable how little Explorer has been tuned over the years.

 

Burt

You are misunderstanding what I am doing, I think. In ME there is a group of commands in Files/Folders. If you select the Copy Files dialog and enter the fields below(listed previously) it will copy as you wish (this only works in c:\temp). This procedure does not use Explorer's Copy command at all. That is why the cursor/highlight does not move.

 

Do as you are doing copying the filename to the clipboard

Variable set string %T1% from the clipboard

Files/Folders Copy...

Files/Path Name: c:\temp\%T1%

New Name: c:\temp\Copy of %T1%

 

You copy the name of file abcd.doc to the clipboard using Explorer

ME makes %T1% equal to text string "abcd.doc"

ME will then copy file c:\temp\abcd.doc as

c:\temp\Copy of abcd.doc

 

I attach a copy of my macro, use File/Import/Import a Playable Macro. Again only works in c:\temp and the filename with extension must be copied from Explorer.

 

There are many easy ways to accomplish what you are really trying to do. I sort and edit between 2,000-5,000 images a day so I consider myself an expert in saving time! First I'll give a really simple free solution followed by the one I actually use.

 

Put all you images in a permanent folder say c:\images_in. Create another permanent folder c:\images_out. When you find an image you want to select, just drag the file with the mouse (copy) into c:\images_out, which is located right next door. When you have finished selecting all the good ones, use a renaming utility like TheRename (freeware by Herve Thouzard) to add "Copy of" to the files in c:\images_out (or however you want to rename).

 

I would be inclined to use an image browser rather than Explorer. Even freeware Irfanview is far better because you can get a sheet of thumbnails. It can also do bulk renaming.

Later correction: I keep forgetting the Thumbnail View in Explorer which is ok for small numbers of images. For large number of images that are going to be frequently accessed, the database style of image browser is better because all the thumbs in a folder are already made and stored.

 

The way I do it is with (payware) Thumbsplus. All the images go in a folder and I have it set so it does not make any thumbnails. I go through the images at fullscreen size. Ones I want to select I hit F3 and it makes the thumbnail. Editing the image also makes the thumbnail. When done selecting, I hit Ctrl+Alt+7 which moves all files WITH thumbnails to the start of the folder. I then move or copy the block of files to another folder and rename or otherwise process. Thumbsplus has a very good renaming utility too.

Explorer_make_copy_of_highlighted_file_c_temp.mxe

Share this post


Link to post
Share on other sites

Well your macro works but I always work in different directories. The directory contains the object name and the "copy of ..." files become samples which I rename and they must stay in the same directory on top of the list.

All this renaming is done with a macro ofcourse!

 

You describe other way''s of working, i'll give that a try.

 

 

But my main question is now: Can Macro Express get the filename and path of a selected file?

 

 

Thanks again

 

ps. The first macro I made was to make a new folder in Explorer.

And maybe give explorer2 a try (http://netez.com/xplorer2/) as an alternative for Powerdesk and Explorer. Even the free version is very powerful.

Share this post


Link to post
Share on other sites
But my main question is now: Can Macro Express get the filename and path of a selected file?

it's quite easy for the path, if you use GetControl / GetControlText on the "address" editbox of your Windows Explorer toolbar ... regarding the filename, maybe you could use a small trick : if your mouse is on the filename you need, a long left click will highlight it for modification (same as right click / rename) and allow you to copy it to clipboard

Share this post


Link to post
Share on other sites

Hello Burt!

 

If I understand the situation from one of your previous posts, you simply want to make a copy of the highlighted filename, using the default "Copy of", saving it to the current folder, and without moving the cursor so that you can keep leisurely scrolling through the folder. The following code works on my system. You may want to adjust the delays up or down to suit your system.

Keystroke Speed: 25 Milliseconds
Text Type: <ALT>ec
Delay 250 Milliseconds
Text Type: <ALT>ep
Keystroke Speed: 0 Milliseconds

<SPKEY:0025><TEXTTYPE:<ALT>ec><MSD:250><TEXTTYPE:<ALT>ep><SPKEY:0000>

Also. there was a question of how to get Macro Express to add the fullpath portion to a simple filename. This is easily done by first copying the name (while in Explorer) to a variable and then using the Variable Set from File Path command to automatically add the drive, path, and so forth.

Share this post


Link to post
Share on other sites

Hey Joe!,

 

Ha, your solution is indeed very simple just do copy&paste. Explorer doesn't move the cursor. The difference is that I use ACDSee and if an a new file gets in the directory it get's selected so the selectionbar jumps down in the list.

I tried to make my question not program specific and I didn't realize that explorer handles this in another way than ACDsee does.

I should have mentioned this immediately.

 

But I want to give it a try with the variables.

 

I discoverd that if I do ctrl-c on a selected file in ACDSee, and paste that in a textfile it pastes the whole <driveletter:\filepath\filename.ext> as plain text, so that makes things easier.

Now the whole path information is clear and I can use the standard file copy functions in ME.

But then again, even if ME copies the files in the same directory, ACDSee will select them, no one can do anything about this I guess.

 

So I have to stick to the macro I made:

 

Text Type: <F2>
Text Type: <CONTROL>c
Text Type: <ESC>
Variable Set String %T1% from Clipboard
Text Type: <CONTROL>c
Text Type: <CONTROL>v
Variable Modify String: Save %T1% to Clipboard
Clipboard Type Text

 

This is my solution which is not perfect but works good, I have to read more about variables and how to use them, its new for me.

 

So thanks for the help, maybe you can give me the exact ME function for

copying the name (while in Explorer) to a variable
as you refer to.

 

And I dont know if you read what I wrote about copying the clipboard contents (a filename) to a textfile and type that texfile as keystrokes with "Clipboard Type Text" (in Explorer).

Because ME adds a Return/Enter in the textfile, the same Return/Enter is executed when you use Clipboard type Text i.e in Explorer which launches the file (I use typing out a filename for selecting a file, this is standard Windows Explorer behaviour). In my situation this is unwanted.

Is this wanted in all other situations, or could this be something for the programmers to change in ME that an (unasked) Return/Enter can set optional or removed in an future version?

 

Thanks for the help.

 

Bye, Burt

Share this post


Link to post
Share on other sites

Hello Burt!

 

Yes, there is a CR/LF sequence added when saving clipboard content to a text file. It is unclear if it is added by Windows or Macro Express, but either way, based on the code in your last post, it is a moot point. You are no longer saving the clipboard to a text file. To answer your question, however, CR/LF characters can be ignored when using the Clipboard Type Text command by checking the Ignore CR/LF checkbox. So the "option to remove them" already exists in this version of Macro Express.

 

As to the code in your last post (specifically the last two lines), you do not need to use the clipboard to type out text. Use the Text Type command instead, since the text is already in a variable:

Text Type: %T1%

And what I meant by:

copying the name (while in Explorer) to a variable

was simply to highlight the filename and then:

Text Type: <ALT>ec
Variable Set String %T1% from Clipboard

Hope all of this helps!

Share this post


Link to post
Share on other sites

Hey Joe,

 

All is clear now for me, thank you for the tip to simplify my macro even more.

 

I am going to play with all the tips and hints, this is really a cool program but a danger for my amount of sleeping hours at night :)

 

 

Hey Nicolas,

 

Thank you for your hints. I'm gonna experiment with those also.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...