Script: auto create folder with file name ...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
conca
Posts: 16
Joined: 18 May 2016, 12:02

Script: auto create folder with file name ...

21 Sep 2017, 10:26

Hi all.
I'd like to create a script to automate this routine:
suppose I've a file named abcd.txt

I'd like to select this file with mouse (left click) and need a script that do:
- create a folder with the name of file (without extension .txt, .mov ecc)
- move the file into created folder (abcd.txt into abcd folder)
- move the folder into a specific path (ex. C:\Users\example\ecc)

It is possible to do ?

Thank u so mutch to anybody
Francesco
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Script: auto create folder with file name ...

21 Sep 2017, 11:08

I'd like to select this file with mouse (left click) and need a script that do: - Send ^c
- create a folder with the name of file (without extension .txt, .mov ecc) - SplitPath
- move the file into created folder (abcd.txt into abcd folder) - FileMove
- move the folder into a specific path (ex. C:\Users\example\ecc) - FileMoveDir

It is possible to do ? - Yes
conca
Posts: 16
Joined: 18 May 2016, 12:02

Re: Script: auto create folder with file name ...

21 Sep 2017, 11:58

tring to study all commands
conca
Posts: 16
Joined: 18 May 2016, 12:02

Re: Script: auto create folder with file name ...

25 Sep 2017, 02:54

FileCreateDir, C:\Users\Farmacia San Paolo\Documents\AHK\Prova
FileMove, C:\Users\Farmacia San Paolo\Documents\AHK\Prova.txt, C:\Users\Farmacia San Paolo\Documents\AHK\Prova\

This script work but I have to do a script that uses a mouse selction insted to file name:

I have this file : C:\Users\Farmacia San Paolo\Documents\AHK\Prova.txt
I'd like to select it with mouse and i need a script to:

FileCreateDir, C:\Users\Farmacia San Paolo\Documents\AHK\"selected file with no extention"
FileMove, C:\Users\Farmacia San Paolo\Documents\AHK\"file selected", C:\Users\Farmacia San Paolo\Documents\AHK\"selected file with no extention"\

how can I do it ?
I have to create a variable ?
please help me
thnx
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Script: auto create folder with file name ...

25 Sep 2017, 04:40

Code: Select all

!F10:: ; press Alt + F10 once you've selected a file in Windows explorer
Send, ^c
MsgBox % "This is the path you've copied with pressing Alt + F10`n" ClipBoard
Return
Not tested. The variable ClipBoard contains the content of the :arrow: ClipBoard.
conca
Posts: 16
Joined: 18 May 2016, 12:02

Re: Script: auto create folder with file name ...

25 Sep 2017, 05:05

Code: Select all

!F10:: ; press Alt + F10 once you've selected a file in Windows explorer
Send, ^c
MsgBox % "This is the path you've copied with pressing Alt + F10`n" ClipBoard
Return
FileCreateDir, C:\Users\Farmacia San Paolo\Documents\AHK\Prova
FileMove, ClipBoard, C:\Users\Farmacia San Paolo\Documents\AHK\Prova\
I have the message box that confirm that path file was copied
But the file in the path doesn't moove
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Script: auto create folder with file name ...

25 Sep 2017, 05:19

Try

Code: Select all

FileMove, % ClipBoard, C:\Users\Farmacia San Paolo\Documents\AHK\Prova\
Please excuse my spelling I am dyslexic.
conca
Posts: 16
Joined: 18 May 2016, 12:02

Re: Script: auto create folder with file name ...

25 Sep 2017, 05:44

Code: Select all

!F10:: ; press Alt + F10 once you've selected a file in Windows explorer
Send, ^c
MsgBox % "This is the path you've copied with pressing Alt + F10`n" ClipBoard

FileCreateDir, C:\Users\Farmacia San Paolo\Documents\AHK\Prova
FileMove, % ClipBoard, C:\Users\Farmacia San Paolo\Documents\AHK\Prova\
Thanks It works !!

Now the next step:
we have fix the variable that is the path of the file: C:\Users\Farmacia San Paolo\Documents\AHK\Prova.txt
but

Code: Select all

FileCreateDir, % ClipBoard
doesn't work
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: Script: auto create folder with file name ...

25 Sep 2017, 06:13

Try this

Code: Select all

#If WinActive("ahk_class CabinetWClass") ; explorer

	!F10:: ; press Alt + F10 once you've selected a file in Windows explorer
	ClipSaved := ClipboardAll ; save the entire clipboard to the variable ClipSaved
	clipboard := "" ; empty the clipboard (start off empty to allow ClipWait to detect when the data has arrived)
	Send, ^c ; copy the selected file
	ClipWait, 2 ; wait for the clipboard to contain data.
	if (!ErrorLevel) ; If NOT ErrorLevel, ClipWait found data on the clipboard
	{
		clipboard = %clipboard% ; convert clipboard to plain text (= copy the path of the selected file)
		Sleep, 300 	; needs a little time to convert the clipboard
		MsgBox, 0, , %clipboard% ,2 ; display the path, 2 sec
		SplitPath, clipboard, name, dir, ext, name_no_ext, drive 	; get the name of the selected file (without extension)
		FileCreateDir, C:\Users\Farmacia San Paolo\Documents\AHK\%name_no_ext%	 ; create a folder with the name of file
		FileMove, %clipboard%, C:\Users\Farmacia San Paolo\Documents\AHK\%name_no_ext%\ ;,  0 = (default) do not overwrite existing files
	}
	else
		MsgBox, No file selected
	Sleep 300
	clipboard := ClipSaved ; restore original clipboard
	return

#if
conca
Posts: 16
Joined: 18 May 2016, 12:02

Re: Script: auto create folder with file name ...

25 Sep 2017, 06:55

Thank you so mutch to GEV
this is the final script:

Code: Select all

#If WinActive("ahk_class CabinetWClass") ; explorer

	!F10:: ; press Alt + F10 once you've selected a file in Windows explorer
	ClipSaved := ClipboardAll ; save the entire clipboard to the variable ClipSaved
	clipboard := "" ; empty the clipboard (start off empty to allow ClipWait to detect when the data has arrived)
	Send, ^c ; copy the selected file
	ClipWait, 2 ; wait for the clipboard to contain data.
	if (!ErrorLevel) ; If NOT ErrorLevel, ClipWait found data on the clipboard
	{
		clipboard = %clipboard% ; convert clipboard to plain text (= copy the path of the selected file)
		Sleep, 300 	; needs a little time to convert the clipboard
		MsgBox, 0, , %clipboard% ,2 ; display the path, 2 sec
		SplitPath, clipboard, name, dir, ext, name_no_ext, drive 	; get the name of the selected file (without extension)
		FileCreateDir, D:\Download\Completi\%name_no_ext%	 ; create a folder with the name of file
		FileMove, %clipboard%, D:\Download\Completi\%name_no_ext% ;,  0 = (default) do not overwrite existing files
		FileMoveDir, D:\Download\Completi\%name_no_ext%, D:\Download\Appo Film\%name_no_ext%
	}
	else
		MsgBox, No file selected
	Sleep 300
	clipboard := ClipSaved ; restore original clipboard
	return

#if
Now All is perfect
thank u again and thanks to all people tried to help me

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, GollyJer, Google [Bot], Lamron750 and 270 guests