I want a BAT file which will change the structure of the Windows 98
folder "My Music" on the hard disc C:. I want the BAT file to go
through all immediate subdirectories in "My Music". If any directory
contains a file with the Windows 98 name "Unknown", then all files in
"Unknown" are to be moved to the directory in which the directory
"Unknown" resides. After this, the "Unknown" directory (now empty) is
to be deleted. This should be done for all subdirectories of "My
Music". |
Clarification of Question by
jpalme-ga
on
21 Apr 2003 01:00 PDT
I thought BAT files could do it, but if you say they won't, you
probably know this much better than me.
Would it work if I could enumerate the actual names of the
subdirectories directly under "My music". Their Windows names tend to
be the same, I do not know how to find the MSDOS name of a file. Such
a solution must also work in case some of the enumerated subdirectory
names do not exist at a particular time.
The alternative of a program in PERL would also be OK for me, if
someone else writes it for me, and tells me how to install PERL on my
computer. Since this a private need I have, not business, I am not
willing to pay a lot for a solution, but my offer of $15 is still
valid.
I mostly use a Macintosh, and I have appletalk between the Mac and the
Windows machine, so a third solution might be to write an applescript
solution for the Mac which moves the files remotely on the PC. I could
to that myself, if that is the best solution to my problem.
|
Clarification of Question by
jpalme-ga
on
21 Apr 2003 01:04 PDT
What is "popsracer-ga"? I searched for it with Google and foud no match!
|
Request for Question Clarification by
theta-ga
on
22 Apr 2003 07:28 PDT
Hi jpalme-ga,
While what you require is not possible with Windows Batch files, it
is quite easy to achieve using the Windows Scripting Host[WSH]. WSH is
Microsoft's replacement for the aging BAT files, and has been shipping
as part of every version of Windows since Windows 98. It allows you to
program your batch files using VBScript, Jscript and other scripting
languages. For more information on the Windows Scripting Host, please
check out the following pages:
- MSDN Online: Windows Scripting
(http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid=28001169)
- Microsoft Windows Script Host: A Universal Script Host for
Scripting Languages
(http://msdn.microsoft.com/archive/en-us/dnarwsh/html/msdn_wsh_wp.asp)
- Windows Script Host 5.6
(http://msdn.microsoft.com/msdnmag/issues/02/05/wsh/default.aspx)
If you are running Windows 98, you probably have WSH 1.0 installed.
You can check the installed version by giving the command
cscript
on the command prompt.
You can download the latest WSH 5.6 [719 KB] from Microsoft's website:
- Windows Script 5.6 for Windows 98, Windows Millennium Edition and
Windows NT 4.0
(http://www.microsoft.com/downloads/details.aspx?FamilyId=0A8A18F6-249C-4A72-BFCF-FC6AF26DC390&displaylang=en)
I have already written and tested a VBScript solution which meets
your requirements. Just to be clear about your needs, this is what the
script does:
- Looks in the *immediate* subfolders of the My Music folder. It
requires you to provide the path to the My Music folder at the
commandline.
- If any of the *immediate* subfolders contain a subfolder named
"Unnamed", all the files contained in the "Unnamed" folder are moved
to its parent folder, and the "Unnamed" folder is deleted.
Please specify if you need any changes made to the working of the
batch script. The script was successfully tested on a Windows 98
computer with WSH 5.6 installed.
I am not posting the code yet since you have not specified whether
you will accept solutions employing WSH as an answer. If you agree to
a WSH based solution, I will post my code, incorporating any changes
you might specify, as the answer.
Regards,
Theta-ga
:-)
|
Request for Question Clarification by
theta-ga
on
25 Apr 2003 07:02 PDT
Hi jpalme-ga,
Are you still interested in an answer to your question?
If you have already found a satisfactory solution, please close
this question by clicking on the "Close Question" button at the top of
the page.
Regards,
Theta-ga
:-)
|
Clarification of Question by
jpalme-ga
on
25 Apr 2003 11:32 PDT
Thank you very much, all of you who have tried to help me. Even if you
have not done the job, you have saved me many hours of trying to get
.BAT files do things they apparently cannot do.
I will write a solution in Applescript on my Macintosh, which will
remotely access the Windows 98 computer via Appletalk. That is the
simplest solution for me.
|
Request for Question Clarification by
mathtalk-ga
on
01 May 2003 09:15 PDT
Hi, jpalme-ga:
Please take a look at my comment at bottom. If you no longer want
help with creating the BAT file, you might want to indicate this by
expiring your question. If you would like to have the details per my
comment, please let me know that you are still interested.
regards, mathtalk-ga
|
Clarification of Question by
jpalme-ga
on
02 May 2003 00:08 PDT
I did that, I wrote
CD \"My Music"
and then
DIR *. > MYFILES.TXT
and got the following listing:
VETENS~1 <KAT> 03-04-27 9.16 Vetenskaps Redaktionen P1
SVERIG~1 <KAT> 03-04-27 9.18 Sveriges Radio P1-s
veckomagasin
SVERIG~2 <KAT> 03-04-27 9.29 Sveriges Radio P1
PROGRA~1 <KAT> 03-04-27 9.32 Programmet dÑr hÑlsan inte
tiger still
ENRESA~1 <KAT> 03-04-27 9.34 En resa genom tiden
INTETM~1 <KAT> 03-04-27 9.37 Intet mÑnskligt Ñr oss
frÑmmande
SVERIG~3 <KAT> 03-04-27 9.39 Sveriges Radio - Ekot
SRRADI~1 <KAT> 03-04-27 9.49 SR Radio Sweden
SRMALM~1 <KAT> 03-04-27 9.52 SR Malmî
OMMéNN~1 <KAT> 03-04-27 9.59 Om mÑnniskor och samhÑlle
OMVèRT~1 <KAT> 03-04-27 10.04 Om vÜrt svenska sprÜk
P1-SAK~1 <KAT> 03-04-27 10.06 P1-s aktuella magasin
VETENS~2 <KAT> 03-04-27 10.50 Vetenskapsredaktionen P1
EVIGTO~1 <KAT> 03-04-27 11.03 Evigt och aktuellt om
kvinnors liv
I know that the immediate subdirectories below these directories all
have the Windows-98 name "Unknown" but I do not know how to find out
what the MSDOS names are of those subdirectories. I tried
CD EVIGTO-1
CD "EVIGTO-1"
CD \"EVIGTO-1"
CD \"My Music"\"EVIGTO-1"
but none of these commands seems to work.
|
Request for Question Clarification by
mathtalk-ga
on
02 May 2003 19:12 PDT
Hi, jpalme-ga:
The first column contains the 8.3 names. So after:
CD "My Documents"\"My Music"
gets you into the main subdirectory you're interested in, you should
do, for example:
DIR EVIGTO~1
to see the contents there. Note that the pentultimate character is a
tilde ~ and not a minus -.
It would be helpful to see the contents of such a subdirectory posted
as a clarification, just to make sure we are in sync on what you are
calling a subdirectory with name "Unknown". Since "Unknown" is only
seven characters, the MSDOS and Win98 names for this folder will
presumably be the same.
regards, mathtalk
|
Clarification of Question by
jpalme-ga
on
03 May 2003 01:28 PDT
I am overwhelmed by all the answers I have got to my query.
Yes, I seem to have CSCRIPT version 5.6 installed on my
Windows 98 computer, and a CSCRIPT solution sounds
perfect for me. Please post the code!
I am not 100% sure if the subwindows below "My Music"
are named "Unkown" as their MS DOS name. I know
that their Windows 98 names are "Unknown" but do
not know how to find what their MS DOS name.
(The directory structure, which I want to simplify, is
the results of running the "Convert media format"
command in Realbrowser. Why Realbrowser
creates this subdirectory structure, I do not know.
It confuses my MP3 reader, that is why I want the
format simplified.)
How do I instruct Google to pay for the solutiuon?
|
Request for Question Clarification by
mathtalk-ga
on
03 May 2003 07:03 PDT
Hi, jpalme-ga:
You previously posted a partial "directory" listing (the output of the
DIR command) of your "My Music" directory. As you will see from that
output, the Windows 98 "long names" appear on the right hand; the
MSDOS 8.3 "short names" appear in the first column, to the left hand.
In between there's a column that identifies directories (vs. files)
and a timestamp.
Thus in the example you tried to work with before, a subdirectory
whose long name is:
Evigt och aktuellt omkvinnors liv
has this short name:
EVIGTO~1
and a timestamp of 11:03 AM on April 27, 2003.
When a Windows 98 filename (or directory name) is as short as
"Unknown", the long and short names should agree. You can verify that
by using the DIR command within the EVIGTO~1 directory. Then you will
see both the "long" and "short" names in separate columns, as just
discussed.
You will not be charged your offered list price of $15 until a
researcher posts an "Answer" to your question.
From your mention of having "CSCRIPT" installed and wanting to have
the code posted, I infer that you would like theta-ga to post an
answer with a scripting solution. To make it perfectly clear, you
might post a clarification saying something like:
"THETA-GA : This customer wants your answer!"
regards, mathtalk-ga
|
Clarification of Question by
jpalme-ga
on
05 May 2003 04:46 PDT
Yes, I think the solution suggested by theta-g sounds good, and would
like his or her WSH script, which seems to be the solution to my
problem.
|
Request for Question Clarification by
theta-ga
on
05 May 2003 23:32 PDT
Hi jpalme-ga
Sorry for the delay in replying. I will post the required script soon.
Regards,
Theta-ga
:-)
|
Hi jpalme-ga ,
I have uploaded a zip file containing the required WSH script to
my server.
- You can download it from:
[ http://www31.brinkster.com/tanm/GA/FileMove.zip ]
- The Zip file(FileMove.zip) contains the WSH script
file(FileMove.wsf). Extract this file to a directory of your choice.
- To run the script, all you need to do is click on it. Once the
script is done, a "Script Done." message will be shown.
The script looks in your "C:\My Music" folder for any subfolders. If
any are found, they are checked for an "unknown" subfolder. Any files
contained in the "Unknown" folder are then moved and the folder is
deleted.
If you want the script to look inside some folder other than "C:\My
Music", then you can open the script file "FileMove.wsf" in Notepad,
and edit the variable BASEDIR to point to the required directory.
Hope this helps.
If you have any queries or require any changes made to the script,
just post a request for a clarification and I will be glad to help you
out.
Please do not rate this answer unless and until you are completely
satisfied with the solution.
Regards,
Theta-ga
:-) |
Request for Answer Clarification by
jpalme-ga
on
09 May 2003 01:53 PDT
Sorry, I could not download that file.
|
Clarification of Answer by
theta-ga
on
09 May 2003 06:31 PDT
Hi jpalme-ga,
I have checked out the download, and it works fine for me. I
recommend that you try downloading the file again.
In case you continue having problems downloading the file, I'm
posting the code for you here.
- Create a new file using any text editor, and name it FileMove.wsf
- Paste the following code(given below inside the BEGIN and END
tags) into the file you just created, and save the file.
************** BEGIN SCRIPT CODE *****************
<job id="FileMove">
<script language="VBScript">
Dim BASEDIR, DIRNAME
BASEDIR = "C:\My Music" ' Base folder name
DIRNAME = "Unknown" ' Directory to search for
'Start scanning the folders
ScanFolders(BASEDIR)
WScript.Echo "Script Done."
'Function scans the base folder looking for any
'subfolders. If any subfolders are found, they
'are sent to the SearchUnknown function
Function ScanFolders(folderspec)
Dim fso, fldrs, f, subFolders
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldrs = fso.GetFolder(folderspec)
Set subFolders= fldrs.SubFolders
For Each f in subFolders
SearchUnknown(f.path) 'Search within subfolder
Next
End Function
'This function scans the given folder to see if a
''Unknown' folder is present or not.
Function SearchUnknown(folderpath)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderpath)
Set sf = f.SubFolders
For Each f1 in sf
if UCase(f1.name) = UCase(DIRNAME) then
'Enable error handling
On Error Resume Next
'Move all the files
fso.MoveFile f1.path & "\*.*",folderpath
If Err.Number <> 0 Then
Wscript.Echo "The folder: " & vbcrlf & _
" " & f1.path & vbcrlf & _
" will not be deleted since the following error" & _
" occurred while trying to copy files from it: " _
& vbcrlf & " " & Err.Description
Err.Clear
Else
fso.DeleteFolder f1.path 'Delete folder
End If
On Error GoTo 0
End if
Next
End Function
</script>
</job>
************** END SCRIPT CODE *****************
- To run this script, all you have to do is click on the FileMove.wsf
file.
NOTE: If you have the latest version of Norton Antivirus installed
and have 'Script Blocking' enabled, you may get an alert message about
a possibly malicious script. This happens because the script accesses
your folders in order to check their names and move files. Just select
"Authorize this script" from the Action list, and the message will go
away forever.
Hope this helps.
If you have any queries or require any changes made to the script,
just post a request for a clarification and I will be glad to help you
out.
Regards,
Theta-ga
:-)
|
Request for Answer Clarification by
jpalme-ga
on
11 May 2003 04:16 PDT
Now my only problem is to find out how to close a question when I have
received a well-working reply!
|
Clarification of Answer by
theta-ga
on
11 May 2003 07:02 PDT
Hi jpalme-ga,
Glad to have been of help. Thanks for the great rating!
Regards,
Theta-ga
:-)
|