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 

Rename list of files added from clipboard

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
farnaby1
Guest





PostPosted: Mon Jul 14, 2008 1:29 pm    Post subject: Rename list of files added from clipboard Reply with quote

Help! - Please don't flame me, but as a newbie I have honestly tried my best to compile a hotkey, say Ctrl A (from previous examples in the Forum) .. which will automatically rename files in a directory (i.e. one row at a time) every time I press Ctrl A - by inserting text saved in the clipboard to the front to the file ..

e.g. if previously saved clipboard = "newbie"
Highlighted filename File.001 -> Ctrl+A -> newbieFile.001 -> return to the next row below in Windows Explorer

Code:
^a::  ; Ctrl+A
WinGetClass, active_class, A
if active_class not in ExploreWClass,CabinetWClass
   return ; Doesn't appear to be explorer, so do nothing.
Send {down}{F2}+{Home}   ; Select just the filename part.
Clipboard := ClipSaved
return


Many thanks Smile
Back to top
BoBo²
Guest





PostPosted: Mon Jul 14, 2008 1:51 pm    Post subject: Reply with quote

Code:
ToAdd := "newbie"
MyPath := "C:\MyDir\MySubDir"
MyFileExt := "*"

Loop, %MyPath%\*.%MyFileExt%
   FileMove, %MyPath%\%A_LoopFileName%, %MyPath%\%ToAdd%%A_LoopFileName%
Back to top
farnaby1
Guest





PostPosted: Mon Jul 14, 2008 3:10 pm    Post subject: Reply with quote

Thanking you kindly for your reply BoBo - but apologies - I still don't get it Embarassed

I am sure I didn't explain myself well the first time .. so would you please be very patient with me Question

I would appreciate your help to compose a script to rename the filename of any file in any directory I choose (by clicking on it) in Windows Explorer - and when using a hotkey (say Ctrl-A), it inserts the text (copied from the clipboard), and inserts this text right to the beginning of the filename of the chosen file ..
After the file has been renamed, it returns to the next file below in the list ..

i.e. clipboard=say "newbie_"
file01.001
file02.001
file03.001
..

becomes say :-

newbie_file01.001
newbie_file02.001
newbie_file03.001
..

whenever I use the hotkey Ctrl-A

Many thanks in advance
Back to top
HugoV



Joined: 27 May 2007
Posts: 531

PostPosted: Mon Jul 14, 2008 3:21 pm    Post subject: Reply with quote

Bobo gave you a way to start, perhaps it is better you use a script that works differently but with a nice GUI:
http://www.autohotkey.com/forum/viewtopic.php?t=29448
(or ditch explorer and use a good file manager such as total commander
which has such functions built (multi rename tool))
Back to top
View user's profile Send private message
Zuzu
Guest





PostPosted: Tue Jul 15, 2008 10:23 am    Post subject: Reply with quote

Hello there -

Lightning Renamer is a fantastic program .. however ..
A hotkey script which will enable one to rename any file "on the fly" from whatever is saved in the clipboard (similar to to Farnaby1's request) will be a tremendous help ...

Any sweet person prepared to take up this challenge?

Zx Razz
Back to top
HugoV



Joined: 27 May 2007
Posts: 531

PostPosted: Tue Jul 15, 2008 10:58 am    Post subject: Reply with quote

Naa would be to easy. Why not try it yourself Question
Back to top
View user's profile Send private message
Zuzu
Guest





PostPosted: Tue Jul 15, 2008 11:28 am    Post subject: Reply with quote

HugoV wrote:
Naa would be to easy. Why not try it yourself Question


HaHa! .. Stop being Big Stuff and admit to everyone this is outside your own expertise! Rolling Eyes

Zx Wink
Back to top
HugoV



Joined: 27 May 2007
Posts: 531

PostPosted: Tue Jul 15, 2008 12:30 pm    Post subject: Reply with quote

Nice try but I won't bite. Try it yourself, post the code you wrote if it doesn't work and then people will help you.
Back to top
View user's profile Send private message
Zuzu
Guest





PostPosted: Tue Jul 15, 2008 5:20 pm    Post subject: Reply with quote

Grrr! Mad

Okay - here is my best attempt (okay I know, I am not a programmer .. and I have tried, but it doesn't work - though it would be helpful if I knew why the hell not ..!)
Is there someone a little more interested in helping me, who could give me some pointers please?

Zx
Code:

^a::  ; Ctrl+A
WinGetClass, active_class, A
if active_class not in ExploreWClass,CabinetWClass
   return ; Doesn't appear to be explorer, so do nothing.
;#IfWinActive, ahk_class ExploreWClass
#.::
clipboard=
loop
    {
Send, ^a
  ClipWait
  If (clipboard=newname) ;break the loop at the last file name
    {
    send, {ESC}
    break
    }
  newname:=RegExReplace(clipboard,"_","") ;
  send, %newname%{ENTER}
  send, {DOWN}
  sleep, 200
  }
#IfWinActive
return
Back to top
HugoV



Joined: 27 May 2007
Posts: 531

PostPosted: Tue Jul 15, 2008 6:44 pm    Post subject: Reply with quote

1) use code tags next time makes it easier to read
2) try this one
Code:
#.::
WinGetClass, active_class, A
if active_class not in ExploreWClass,CabinetWClass
   return ; Doesn't appear to be explorer, so do nothing.
ToAdd:=Clipboard ; store clipboard data because we need it later   
clipboard= ; clear clipboard
Send, ^a ; select all
Send, ^c ; copy full path + file names to clipboard (see AHK doc)
Loop, Parse, Clipboard, `r, `n
{
SplitPath, A_loopField, name, dir ; store the original name and directory in name and dir
FileMove, %dir%\%name%, %dir%\%ToAdd%%name% ; insert ToAdd which we copied from the clipboard and rename files (see AHK doc)
}
Return
Use at your own risk
Back to top
View user's profile Send private message
Farnaby1
Guest





PostPosted: Wed Jul 16, 2008 11:37 am    Post subject: Reply with quote

Hi Zuzu -

Did the script which HugoV posted, work for you?
It still doesn't work for me .. though I am very grateful for HugoV's efforts on our behalf Very Happy
After compiling the script, I tried executing the hotkey Ctrl-A, but nothing seems to happen?

Crying or Very sad
Back to top
HugoV



Joined: 27 May 2007
Posts: 531

PostPosted: Wed Jul 16, 2008 11:44 am    Post subject: Reply with quote

1) no need to compile
2) ctrl-a is removed as hotkey (why do you need it?)
3) press windowskey & dot
Back to top
View user's profile Send private message
farnaby1
Guest





PostPosted: Sat Jul 19, 2008 5:58 pm    Post subject: Reply with quote

Hello there -

I am SOO Excited to share this with one and all - after finally cracking the code Laughing (with huge thanks to HugoV for his valued and strategic help Idea He deserves a bouquet --'-,-'-{@ )
I now have the script i was looking for :-
Code:
#.::
WinGetClass, active_class, A
if active_class not in ExploreWClass,CabinetWClass
   return ; Doesn't appear to be explorer, so do nothing.
ToAdd:=Clipboard ; store clipboard data because we need it later   
Send, {F2}{HOME}{CTRLDOWN}v{CTRLUP}{ENTER}{DOWN}
Loop, Parse, Clipboard, `r, `n
{
SplitPath, A_loopField, name, dir ; store the original name and directory in name and dir
FileMove, %dir%\%name%, %dir%\%ToAdd%%name% ; insert ToAdd which we copied from the clipboard and rename files (see AHK doc)
}
Return


Yay!!!!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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