Create folder and move file function button

English support forum

Moderators: Hacker, petermad, Stefan2, white

User avatar
Peter
Power Member
Power Member
Posts: 2068
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

Hello Holger

thanks for the script, but I get:

"Fehler beim Programmaufruf" (Error on starting program??)

That is what I did:

Code: Select all

- took your code and saved it as VBS
- made an icon in a toolbar:
   Command: d:\Program Files\totalcmd\Batches\MoveFiles2SubFolders.vbs
    Parameter: %L 6
    Startpath: D:\Program Files\totalcmd\Batches
    Iconsfile: C:\WINNT\System32\WScript.exe
    Tooltip: Move fle(s) to sub folder(s)
Everytime I use the icon (none file selected; one or many files selected) I get the error.

Peter
TC 10.xx / #266191
Win 10 x64
User avatar
petermad
Power Member
Power Member
Posts: 16032
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2Peter
Maybe Windows Script Host isn't installed on your computer? Do you have wscript.exe or cscript.exe in your system32 folder?
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
HolgerK
Power Member
Power Member
Posts: 5409
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Seems to be a problem with the "Windows Scripting Host" installation or .vbs-file association.

Try this button

Code: Select all

Command: C:\WINNT\System32\WScript.exe 
Parameter: "d:\Program Files\totalcmd\Batches\Test.vbs" 
Iconsfile: C:\WINNT\System32\WScript.exe 
with
Test.vbs wrote:WScript.Echo "Scripting host is available"
If this doesn't work, please reinstall. Windows Script 5.6 for Windows XP and Windows 2000
or upgrade to Windows Script 5.7 for Windows XP

If this test is OK, please check the .vbs file association.
.vbs files should be associated via context menu "Open with" to "Microsoft (r) Windows Based Script Host"

HTH,
Holger

Edit: added "Quotes" in parameter field
User avatar
Peter
Power Member
Power Member
Posts: 2068
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

petermad wrote:2Peter
Maybe Windows Script Host isn't installed on your computer? Do you have wscript.exe or cscript.exe in your system32 folder?
Yes, I have..
And other scripts for the script-plugin work well.
HolgerK wrote:...
Test.vbs wrote:WScript.Echo "Scripting host is available"
...
Yes, it works.
HolgerK wrote:...If this test is OK, please check the .vbs file association.
.vbs files should be associated via context menu "Open with" to "Microsoft (r) Windows Based Script Host"..
My entries where:

Code: Select all

Type: VBScript-Skriptdatei
Action: ---- (none)
I addded:

Code: Select all

Action: open C:\WINNT\system32\wscript.exe %1
Now I get the message (in german):

Code: Select all

Skript:  d:\Program Files\totalcmd\Batches\MoveFiles2SubFolders.vbs
Zeile:   11
Zeichen: 1
Fehler:  Index außerhalb des gültigen Bereichs
Code:    800A0009
Quelle:  Laufzeitfehler in Microsoft VBScript

Line 11 is in whole code

Code: Select all

sFileList = WScript.arguments.Item( 0 ) 
or, when removed all comments and empty lines:

Code: Select all

   sFilePathName = oTextStream.ReadLine 
Peter
TC 10.xx / #266191
Win 10 x64
User avatar
HolgerK
Power Member
Power Member
Posts: 5409
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Action: open C:\WINNT\system32\wscript.exe %1
This should be:

Code: Select all

Action: open C:\WINNT\system32\WScript.exe "%1" %*
otherwise the arguments for the script are not passed to the script.
(exactly this is complained in line 11 : WScript.arguments.Count is 0! The Item(0) does not exist)
I recommend to reinstall the windows scripting host.

HTH,
Holger
User avatar
Peter
Power Member
Power Member
Posts: 2068
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

Now it works - thanks a lot, Holger.

Peter
TC 10.xx / #266191
Win 10 x64
buda
Junior Member
Junior Member
Posts: 11
Joined: 2007-06-16, 00:23 UTC

fail to recognise chinese filename

Post by *buda »

Have tried the MoveFiles2SubFolders.vbs,but it fail to do so.My file all in Chinese characters,when folder created then the folder name will be shorter than the original text filename.I think this is problems of chinese text only.

Is there a solution for this language?I first find your vbs very happy,but because of the problem,I have to manually amend the folder name,it is only have half the character of the full text filename. :(

e.g.
original text filaname:解答疑難和開示.txt
result folder filename:解答疑難和開

:cry:

Can somebody help?Thanks in advance
User avatar
Peter
Power Member
Power Member
Posts: 2068
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Re: fail to recognise chinese filename

Post by *Peter »

buda wrote:..original text filaname:解答疑難和開示.txt
result folder filename:解答疑難和開
Look at the
Parameter: %L 6

If you use "6", the length will be 6 letters long; if you change it to "9", the script will take 9.

Peter
TC 10.xx / #266191
Win 10 x64
buda
Junior Member
Junior Member
Posts: 11
Joined: 2007-06-16, 00:23 UTC

Post by *buda »

:lol:
you are very intelligent man,it really works,thanks again all of you. :P
crystal3d
Junior Member
Junior Member
Posts: 7
Joined: 2011-08-14, 19:14 UTC

Post by *crystal3d »

this create new button part confuses me the most.

should not this be enough?

save the vbs to some location

create a button,

command: location\the_vbs_script.vbs
parameters: %L -1 1
User avatar
HolgerK
Power Member
Power Member
Posts: 5409
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

should not this be enough?
Yes it is.
instead of "create a button" you can also drag 'n drop the saved vbs file on an empty place of the button bar.

this create new button part confuses me the most

Create a new button:

Code: Select all

TOTALCMD#BAR#DATA
C:\Tools\totalcmd\Scripts\MoveFiles2SubFolders.vbs
%L 6
C:\Windows\System32\WScript.exe
Move file(s) to sub folder(s)
C:\Tools\totalcmd\Scripts\

-1 
Just as short explanation against your confusion.
The code block above contains the clipboard content of a button created using the context menu command "copy" of my personal test button.

- You can mark the code block content again and copy the marked block into the clipboard.
- Paste it (using the context menu) onto a empty place of your button bar to create a new button.

A very simple way to submit button declarations within a forum post.

But you need to adapt the location of your saved vbs file and change the parameter field from "%L" 6 to "%L" -1 1, otherwise only the first 6 characters would be used to create the folder.
So you're right, what you did was easier in this case.

Regards
Holger
Post Reply