User level cmd script need's a little help


WyattCollins

Well-known member
Member
Local time
2:52 PM
Posts
43
OS
Windows 11 Home 64-bit v10.0.26200 N/A Build 26200
I'm working on a script and need a little help with it.
Please critique and make suggestion's to improve the script and what it does.

I would like "one-liner's" where possible.
Look's like it need's some 'tidy-up'.

The script is meant to be manually ran under the C:\Users directory.
It delete's unneeded file's from the source directories.
Move's needed file's to a destination directory.
Append's a file extension to each needed file.
Delete's empty subdirectories from the source directory.
Retain's the source and destination directories.

Can I keep this script in a Desktop folder?
Does this script need an upper level cmd prompt for it to work?
Which is better for a user level script such as this, *.bat or *.cmd?

When I first ran this script, I ran it from C:\Windows\System32.
Cmd (Admin) threw error's, question's and info messages at me.
These were such like...
"... [source directory, Are you sure? [Y] or [N]"
"Cannot specify the system"
"...Access is Denied"
What would I append into the script to have cmd echo the line number and phrase within that line which cause's these message's?

I read on the internet that the "::" is another way of writing "rem".
The only info about the "::" statement that the the author of that tutorial was specific about is that whatever is behind rem and :: is ignored.
Is that true or are there some thing's going on such as what the help page seem's to suggest about rem?

The
Code:
help rem
say's
Records comments (remarks) in a batch file or CONFIG.SYS.

REM [comment]
Does it mean that line's beginning with rem is recorded in a file somewhere on the machine?
If so, what and where is that file and how would I prevent commands from being endlessly recorded?

The script...
Code:
@echo off
rem Delete unneeded files from source
del /s /q /a:- product*
del C:\Wyatt\Desktop\Test-Dir\5d\8d\product191_5d8d4c8a48e6e57c6b6af733e58923c2
del C:\Wyatt\Desktop\Test-Dir\dd\a8\product10968_dda8f69897aaa227624eb10e438512ee
del C:\Wyatt\Desktop\Test-Dir\f8\0b\product3205724_f80b9c604e691456970cf41d41aeee31

:: Move and rename files from source subdirectories and give the extension *.png to each file
move /y C:\Users\Wyatt\Desktop\Test-Dir\0b\8b\0b8bca5651664e27a343fb71586eb7f7 C:\Users\Wyatt\Desktop\Test-Dir\0b8bca5651664e27a343fb71586eb7f7.png
move /y C:\Users\Wyatt\Desktop\Test-Dir\3b\49\3b491db53fce5f9e48ffd1b4ea8f01eb C:\Users\Wyatt\Desktop\Test-Dir\3b491db53fce5f9e48ffd1b4ea8f01eb.png
move /y C:\Users\Wyatt\Desktop\Test-Dir\6a\50\6a50af3f8a6682a27083da35675f6ec5 C:\Users\Wyatt\Desktop\Test-Dir\6a50af3f8a6682a27083da35675f6ec5.png

:: Remove subdirectories from source
rmdir /s /q C:\Users\Wyatt\Desktop\Test-Dir\*
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\5d\8d
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\5d
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\dd\a8
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\dd
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\f8\0b
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\f8
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\0b\8b
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\0b
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\3b\49
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\3b
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\6a\50
rd /s /q C:\Users\Wyatt\Desktop\Test-Dir\6a
 

My Computer My Computer

At a glance

Windows 11 Home 64-bit v10.0.26200 N/A Build ...Intel(R) Core(TM) i3-N305 (1.80 GHz)8.00 GB (7.70 GB usable)8.00 GB (7.70 GB usable)
OS
Windows 11 Home 64-bit v10.0.26200 N/A Build 26200
Computer type
Laptop
Manufacturer/Model
Lenovo 82XB IdeaPad Slim 3 15IAN8
CPU
Intel(R) Core(TM) i3-N305 (1.80 GHz)
Memory
8.00 GB (7.70 GB usable)
Graphics Card(s)
8.00 GB (7.70 GB usable)
Hard Drives
238 GB SSD
Mouse
ELAN touchpad; Logitech Wireless
You're calling it a Script, but it looks a lot like DOS Batch Language to me.
I do write batch files, like my "Windows11Cleanup.bat" program which I've talked about a lot on this and other forums, and I've shared with many members.
Save it with the .bat extension, to a folder on C:\ and then create a shortcut to your desktop, with "Run as Administrator" privileges.

As for the commands, as you've typed them, they look legit! That is if the paths and file names are correct.
But personally, I'm still at a loss as to what you're trying to do.

That one line looses me though. (del /s /q /a:- product*) It might make more sense to me, anyway, if it read, del /s/q/f C:\Product.*
The /a switch is used in reference to a certain file attribute. I don't see an attribute being specified.

Good luck,
TM :cool:
 
Last edited:
Yes, it is a DOS Batch language.
In my thinking, I believe the file as a whole is a script of some sort.

The original post specifies what I ran into and contain's a few question's.
Hopefully, those question's are answered very soon by other such file's ;-)
Or by members here :-)
 

My Computer My Computer

At a glance

Windows 11 Home 64-bit v10.0.26200 N/A Build ...Intel(R) Core(TM) i3-N305 (1.80 GHz)8.00 GB (7.70 GB usable)8.00 GB (7.70 GB usable)
OS
Windows 11 Home 64-bit v10.0.26200 N/A Build 26200
Computer type
Laptop
Manufacturer/Model
Lenovo 82XB IdeaPad Slim 3 15IAN8
CPU
Intel(R) Core(TM) i3-N305 (1.80 GHz)
Memory
8.00 GB (7.70 GB usable)
Graphics Card(s)
8.00 GB (7.70 GB usable)
Hard Drives
238 GB SSD
Mouse
ELAN touchpad; Logitech Wireless
Back
Top Bottom