{"id":5083,"date":"2021-11-12T10:34:41","date_gmt":"2021-11-12T10:34:41","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=5083"},"modified":"2021-11-12T10:35:04","modified_gmt":"2021-11-12T10:35:04","slug":"how-do-i-rename-a-file-using-clipboard-contents","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/how-do-i-rename-a-file-using-clipboard-contents\/28777.html","title":{"rendered":"How Do I Rename A File Using Clipboard Contents?"},"content":{"rendered":"<p>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&#8217;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?<\/p>\n<p>Example:<\/p>\n<p>@echo off<br \/>\n::Get Serial from WMI to clipboard<br \/>\necho Getting Serial Number<br \/>\n::get serial and save in txt file<br \/>\nwmic bios get serialnumber &gt; sn1.txt<br \/>\n::parse file, remove &#8220;serialnumber&#8221; text and move relevant data to sn2<br \/>\ntype sn1.txt | findstr \/v SerialNumber &gt; sn2.txt<br \/>\n::sn1.txt not needed, deleting<br \/>\ndel sn1.txt<br \/>\n::copy content of sn2.txt to clipboard<br \/>\nclip &lt; sn2.txt<\/p>\n<p>At this point in the script, it&#8217;s taken the contents of sn1.txt:<\/p>\n<p>SerialNumber<br \/>\nserial#1234abcd<\/p>\n<p>Removed the first line and dumped the rest to sn2.txt as follows:<\/p>\n<p>serial#1234abcd<\/p>\n<p>From here that same info is copied to the clipboard.<\/p>\n<p>How would I script it so that either the file or clipboard contents can be used to rename the file?<\/p>\n<p>sn2.txt &gt; serial#1234abcd.txt<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":2},"question-category":[55],"question_tags":[],"class_list":["post-5083","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/5083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=5083"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=5083"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=5083"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=5083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}