User level cmd script need's a little help


WyattCollins

Member
Local time
5:39 AM
Posts
19
OS
Windows 11 Home 64-bit ver=22H2 build=22621.1702
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

System One

  • OS
    Windows 11 Home 64-bit ver=22H2 build=22621.1702
    Computer type
    Laptop
    Manufacturer/Model
    HP 15-ef1105nr
    CPU
    AMD Athlon™ Silver 3050U
    Motherboard
    HP 8706 99.43 AMD Ryzen SOC rev. 00/FCH rev. 51 PCI-Express 3.0 (8.0 GT/s)
    Memory
    4 GB DDR4-2400 MHz RAM (1 x 4 GB)
    Graphics Card(s)
    HP AMD Radeon™ Graphics 400MHz GFX core
    Sound Card
    AMD/Realtek HD Audio Device
    Monitor(s) Displays
    15.6" HD LED (220 nits)
    Screen Resolution
    1366 x 768
    Hard Drives
    128 GB SATA 3 TLC M.2 SSD
    PSU
    45 W Smart AC power adapter; 3-cell, 41 Wh Li-ion
    Keyboard
    HPQ Standard PS/2
    Mouse
    ELAN touchpad; Logitech Wireless
    Internet Speed
    2.4 GHz/144 Mbps Realtek RTL8822CE 802.11ac PCIe Adapter
    Browser
    Google Chrome Version 115.0.5790.171 (Official Build) (64-bit)
    Antivirus
    McAfee LiveSafe™ (may get replaced with something more efficient)
    Other Info
    No optical drive; DirectX 12; HP True Vision 720p HD Webcam; BIOS: AMD AGESA PicassoPI-FP5 1.0.0.E UEFI; CCleaner; Glary Utilities; Speccy; CPU-Z; GPU-Z
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:

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
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

System One

  • OS
    Windows 11 Home 64-bit ver=22H2 build=22621.1702
    Computer type
    Laptop
    Manufacturer/Model
    HP 15-ef1105nr
    CPU
    AMD Athlon™ Silver 3050U
    Motherboard
    HP 8706 99.43 AMD Ryzen SOC rev. 00/FCH rev. 51 PCI-Express 3.0 (8.0 GT/s)
    Memory
    4 GB DDR4-2400 MHz RAM (1 x 4 GB)
    Graphics Card(s)
    HP AMD Radeon™ Graphics 400MHz GFX core
    Sound Card
    AMD/Realtek HD Audio Device
    Monitor(s) Displays
    15.6" HD LED (220 nits)
    Screen Resolution
    1366 x 768
    Hard Drives
    128 GB SATA 3 TLC M.2 SSD
    PSU
    45 W Smart AC power adapter; 3-cell, 41 Wh Li-ion
    Keyboard
    HPQ Standard PS/2
    Mouse
    ELAN touchpad; Logitech Wireless
    Internet Speed
    2.4 GHz/144 Mbps Realtek RTL8822CE 802.11ac PCIe Adapter
    Browser
    Google Chrome Version 115.0.5790.171 (Official Build) (64-bit)
    Antivirus
    McAfee LiveSafe™ (may get replaced with something more efficient)
    Other Info
    No optical drive; DirectX 12; HP True Vision 720p HD Webcam; BIOS: AMD AGESA PicassoPI-FP5 1.0.0.E UEFI; CCleaner; Glary Utilities; Speccy; CPU-Z; GPU-Z

Latest Support Threads

Back
Top Bottom