Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Create folder and move file function button
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Total Commander Forum Index -> Total Commander (English) Printable version
View previous topic :: View next topic  
Author Message
jbw92
Junior Member
Junior Member


Joined: 13 Dec 2003
Posts: 5

PostPosted: Sun Nov 11, 2007 2:52 pm    Post subject: Create folder and move file function button Reply with quote

Hi all,

Often i create a folder by pressing F7 after selecting a file (without file exension).
Thereafter i move the file into the created folder.


Can this be done by adding a button+function to the buttonbar?
If yes can you please advise how to do this?

TIA
Joop
Back to top
View user's profile Send private message
ts4242
Power Member
Power Member


Joined: 02 Feb 2004
Posts: 1501
Location: Egypt

PostPosted: Sun Nov 11, 2007 3:09 pm    Post subject: Reply with quote

1. go to menu Configuration> Cange button bar...
2. add new button
3. browse internal commands and select cm_MkDir command
4. press OK
_________________
Author of Ultra TC Editors
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Stitscher
Power Member
Power Member


Joined: 17 Feb 2004
Posts: 1060
Location: Hamburg, Germany

PostPosted: Sun Nov 11, 2007 3:25 pm    Post subject: Reply with quote

2ts4242
But cm_mkdir doesn't move the slected file in the folder. Wink

Stitscher
Back to top
View user's profile Send private message Send e-mail
jbw92
Junior Member
Junior Member


Joined: 13 Dec 2003
Posts: 5

PostPosted: Sun Nov 11, 2007 3:27 pm    Post subject: Reply with quote

Thanx for the reply.
What you describe is what is achieved by selecting the filename and pressing F7. No problem.
What i want is that also the selected file is moved to the created folder by pressing the same button.

TIA
Joop
Back to top
View user's profile Send private message
Vansumsen
Power Member
Power Member


Joined: 09 Nov 2003
Posts: 761
Location: Belgique

PostPosted: Sun Nov 11, 2007 3:35 pm    Post subject: Reply with quote

Arrow jbw92

1° create those two em_command : (See the Tutorial to know how to do)

[em_dir]
cmd=%comspec% /c md
param="%T%O"

[em_copy]
cmd=%comspec% /c copy
param="%p%N" "%T%O" /b

2°Dowload and install the (tiny) tool TCMC available here >>> http://totalcmd.pl/download/add/Add/TC_Multiple_Commands

(I propose you to install this tool here : C:\Totalcmd\Tools\TCMC)

3°Create a new button :

cmd=C:\Totalcmd\Tools\TCMC\TCMC.exe 500 EMem_dir EMem_copy
Icon=Your personal choice
Comment=Create a directory with a file name and copy the file in this new dir

To use the button : Select a file into the source panel, click on the button, the directory is created in the destination panel...

Enjoy

Paul
_________________
Ouistiti, #11943

L'important n'est pas de convaincre, mais de donner à réfléchir.
The important thing is not to convince, but to incite to think.

1,77245385090552...
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
jbw92
Junior Member
Junior Member


Joined: 13 Dec 2003
Posts: 5

PostPosted: Sun Nov 11, 2007 4:04 pm    Post subject: Reply with quote

Thanx for the very fast reply.
Will try tomorrow.

Joop
Back to top
View user's profile Send private message
HolgerK
Power Member
Power Member


Joined: 26 Jan 2006
Posts: 3563
Location: Europe, Aachen

PostPosted: Sun Nov 11, 2007 5:51 pm    Post subject: Reply with quote

Small enhancement.
This can be done with one single command:
Code:
[em_mkdirAndCopyFile]
cmd=%comspec% /c
param= md "%T%O" && copy %P%N "%T%O\" /b

Or as original asked:
Code:
[em_mkdirAndMoveFile]
cmd=%comspec% /c
param=md "%T%O" && move %P%N "%T%O\"


No need to use TCMC here.

The final button should look like this:
Code:
TOTALCMD#BAR#DATA
%comspec% /c
md "%T%O" && move %P%N "%T%O\"
%Commander_Path%\WCMICONS.DLL,63
Move file under cursor into new directory

1
-1


Thanks to Vansumsen for the idea Smile

HTH,
Holger
Back to top
View user's profile Send private message Send e-mail
petermad
Power Member
Power Member


Joined: 05 Feb 2003
Posts: 5351
Location: Valsted, Denmark

PostPosted: Mon Nov 12, 2007 10:32 am    Post subject: Reply with quote

2HolgerK

Notice that it only works if %comspec% points to cmd.exe not if it points to command.com - hence not in Win 9x.
_________________
#524
Danish Total Commander Translator
Windows XP Home 32bit SP3 & Windows 7 Home Premium 64bit SP1 and Windows 8. TC 8.01 32 + 64bit

Get Extended Total Commander Menus
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jbw92
Junior Member
Junior Member


Joined: 13 Dec 2003
Posts: 5

PostPosted: Mon Nov 12, 2007 2:08 pm    Post subject: Reply with quote

Arrow HolgerK

This is it (almost). Thank you very Dutch Wink
Is it possible to perform the function in the same folder (not the opposing one)?
What is the function / which file to edit for:
Code:
TOTALCMD#BAR#DATA
%comspec% /c
md "%T%O" && move %P%N "%T%O\"
%Commander_Path%\WCMICONS.DLL,63
Move file under cursor into new directory

1
-1
Back to top
View user's profile Send private message
Peter
Power Member
Power Member


Joined: 13 Nov 2003
Posts: 1570
Location: Schweiz

PostPosted: Mon Nov 12, 2007 2:33 pm    Post subject: Reply with quote

HolgerK wrote:
...
param= md "%T%O" && copy %P%N "%T%O\" /b[/code]
...

Is it possible to use parts of the filename to create folders?

Example:

I have files which begins with the same letters (abc-456-ph1-inda.txt; abc-456-ph1-indb.txt; abc-456-ph2-inda.txt, ...) and want to
- "select the filename until the second "-" or (select the first 7 letters of the filename) -> result: "abc-456"
- make a folder with this name
- move all selected files to the new folder

Peter
_________________
TC 8.01 / #266191
Windows XP 32 Professional & Win 7 x64
Back to top
View user's profile Send private message Send e-mail Visit poster's website
HolgerK
Power Member
Power Member


Joined: 26 Jan 2006
Posts: 3563
Location: Europe, Aachen

PostPosted: Mon Nov 12, 2007 6:45 pm    Post subject: Reply with quote

petermad wrote:
2HolgerK

Notice that it only works if %comspec% points to cmd.exe not if it points to command.com - hence not in Win 9x.

You're right.

Sometime during the last century, I decided to skip this (can I say?) operation system.
OS/2 was the better environment for DOS development, Windows NT4 was the better base for windows development.
I never regretted this decision.

So for all 16Bit Dos / 32(*3/4)Windows 9x Hardliner: Vansumsen suggestion is the better way in this case. At least if the command line does not exceed the 127/255 character limit.

Kind regards,
Holger
Back to top
View user's profile Send private message Send e-mail
HolgerK
Power Member
Power Member


Joined: 26 Jan 2006
Posts: 3563
Location: Europe, Aachen

PostPosted: Mon Nov 12, 2007 6:50 pm    Post subject: Reply with quote

jbw92 wrote:
Arrow HolgerK

This is it (almost). Thank you very Dutch Wink
Is it possible to perform the function in the same folder (not the opposing one)?
What is the function / which file to edit for: ...

Two solutions:

A) use <Ctrl+Left> or <Ctrl+Right> to synchronize the two panels

B) replace %T with %P :
Code:
TOTALCMD#BAR#DATA
%comspec% /c
? md "%P%O" && move %P%N "%P%O\"
%Commander_Path%\WCMICONS.DLL,63
Move file under cursor into new directory

1
-1


HTH,
Holger


Last edited by HolgerK on Mon Nov 12, 2007 7:16 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
HolgerK
Power Member
Power Member


Joined: 26 Jan 2006
Posts: 3563
Location: Europe, Aachen

PostPosted: Mon Nov 12, 2007 7:15 pm    Post subject: Reply with quote

Peter wrote:
HolgerK wrote:
...
param= md "%T%O" && copy %P%N "%T%O\" /b[/code]
...

Is it possible to use parts of the filename to create folders?
...


Maybe the following line will give you a hint how to do this with Batch-programming:
Code:
for /F "eol=; tokens=1,2,3* delims=-." %i in ("abc-456-ph1-inda.txt") do @echo %i-%j

Replace abc-456-ph1-inda.txt with %O
and echo %i-%j with set TT="%%T%i-%j" && md %TT%
Untested!
Personal i would use a VB-script in this case. Better error handling, string operations and the FileSystemObject is easy to use in this place.
The following script could be used as base for your special wish CreateMarkedDirs.vbs

With a little knowledge in VisualBasic programming it should be no problem to adapt this small script.

HTH,
Holger
Back to top
View user's profile Send private message Send e-mail
Peter
Power Member
Power Member


Joined: 13 Nov 2003
Posts: 1570
Location: Schweiz

PostPosted: Tue Nov 13, 2007 6:39 am    Post subject: Reply with quote

Hello

you should take a look at

http://www.totalcmd.net/plugring/Mover.html (incl. source code)

This is a function which handles with "makedir" and "moving". Maybe there is someone who can modfiy the code for all needs?

Peter
_________________
TC 8.01 / #266191
Windows XP 32 Professional & Win 7 x64
Back to top
View user's profile Send private message Send e-mail Visit poster's website
HolgerK
Power Member
Power Member


Joined: 26 Jan 2006
Posts: 3563
Location: Europe, Aachen

PostPosted: Tue Nov 13, 2007 6:09 pm    Post subject: Reply with quote

Sorry Peter

Actual i have less spare time to do plugin development.
Another point is, that may be Christian can add a "create directory" possibility into the MRT.
This would simplify the task of this thread to a simple file rename mask ( "[N1-5]\[N]" or [N]\[N]).
( Still hoping) Smile

In the meantime you can test this litlle basic script:
Code:
'Command   : MoveFiles2SubFolders.vbs
'Parameters: %L -1 1
'Tooltip   : move all marked files into subfolder with the basename of the file
' # first parameter %L Name of a list file with long file names including the complete path
' # (opt) second parameter can be use to create folders from the first N character of the filename
'       if N is less then 1, the complete filename without extension is used as new folder name
' #  (opt) third parameter (silent mode) if set to 0. all expected error messages are skipped

Const FOR_READING = 1

sFileList = WScript.arguments.Item( 0 )
nLength = -1
bSilent = false
If WScript.arguments.Count > 1 Then   nLength = WScript.arguments.Item( 1 )
If WScript.arguments.Count > 2 Then   If WScript.arguments.Item( 2 ) = 0 Then bSilent = true

Set oFSO = CreateObject( "Scripting.FileSystemObject" )

If  oFSO.FileExists(sFileList) Then

  Set oTextStream = oFSO.OpenTextFile( sFileList, FOR_READING )
  Do Until oTextStream.AtEndOfStream

   sFilePathName = oTextStream.ReadLine
   If  oFSO.FileExists( sFilePathName ) Then
   
      sPath = oFSO.GetParentFolderName( sFilePathName )
      sName = oFSO.GetBaseName( sFilePathName )
      sExtension = oFSO.GetExtensionName( sFilePathName )
      If nLength < 1 Then
         sNewPath = sPath & "\" & sName
      Else
         sNewPath = sPath & "\" & Left( sName, nLength )
      End If

      sNewFilePathName = sNewPath & "\" & sName & "." & sExtension

      If Not oFSO.FileExists( sNewPath ) Then
      
         If Not oFSO.FolderExists( sNewPath ) Then
            oFSO.CreateFolder( sNewPath )
         End If

         If Not oFSO.FileExists( sNewFilePathName ) Then
            oFSO.MoveFile  sFilePathName, sNewFilePathName
         ElseIf not bSilent then
            WScript.Echo "Destination File exists (skipped)!: " & sNewFilePathName
         End If
         
      ElseIf not bSilent then
         WScript.Echo "File with destination folder name exists already (skipped)!: " & sNewPath
      End If
   End If
  Loop
 
  oTextStream.Close
 
Else

  WScript.Echo "Input file list " & sFileList & " not found."
 
End If


Save the script as "MoveFiles2SubFolders.vbs"

Create a new button:
Code:
TOTALCMD#BAR#DATA
C:\Tools\totalcmd\Scripts\MoveFiles2SubFolders.vbs
%L 6
C:\Windows\System32\WScript.exe
Move fle(s) to 2 sub folder(s)
C:\Tools\totalcmd\Scripts\

-1


Compared to the above dos-commands, this script should also work correct with filenames containing german "umlaut"(s), and can handle more than one file in a single call.

Kind regards,
Holger
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> Total Commander (English) All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group