Solved How do I rename a file using clipboard contents?

January 7, 2013 at 04:57:43
Specs: Windows 7

I have a startup script that gets the serial number from a machine using wmi. I created this script to use when imaging a computer and setting it up with prey. It gets the system serial number then calls the prey-config.exe and allows me to paste the serial number in from the clipboard. I'm trying to automate the process as much as possible, so being able to generate a filename using the clipboard contents is what eludes me at this point. Any suggestions to get me going in the right direction?


@echo off
::Get Serial from WMI to clipboard
echo Getting Serial Number
::get serial and save in txt file
wmic bios get serialnumber > sn1.txt
::parse file, remove "serialnumber" text and move relevant data to sn2
type sn1.txt | findstr /v SerialNumber > sn2.txt
::sn1.txt not needed, deleting
del sn1.txt
::copy content of sn2.txt to clipboard
clip < sn2.txt

At this point in the script, it's taken the contents of sn1.txt:


Removed the first line and dumped the rest to sn2.txt as follows:


From here that same info is copied to the clipboard.

How would I script it so that either the file or clipboard contents can be used to rename the file?

sn2.txt > serial#1234abcd.txt

See More: How do I rename a file using clipboard contents?

Report •

January 7, 2013 at 14:28:51
✔ Best Answer

for /f "skip=1 tokens=*" %%i in (sn2.txt) do move /y sn2.txt "%%i.txt"


Report •
Related Solutions

Ask Question