How to add "and" function to a BAT file to copy files and then rename
Go to solution
Solved by mariushm,
why don't you write a basic script in php or some other language?
A php script can be run from command line, simply say c:\programs\php\php.exe c:\path\to\your\php_script.php - you can make it a shortcut if you want.
(assuming php is unpacked/installed in c:\programs\php folder)
A basic php script would be something like this (I'm literally writing the code in this comment box so it probably has some errors but you can read the php documentation and figure things out) :
<?php // the folder where you want to look for files, use / instead of \, // or if you want to use \, escape it by writing \\ instead of \ $folder_search = "C:/Users/Rohith/AppData/Local/Packages/Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy/LocalState/Assets/"; // where to copy the files $folder_destination = "Q:/D Drive/D Drive/Wallpaper/Rohith/New folder (2)/"; // is it a proper folder? if (is_dir($folder_search)) { // try to open a handle to the folder so we can read contents if ($folder_handle = opendir($folder_search)) { // opened folder, now read all the folders and file names from the folder while (($filename = readdir($folder_handle)) !== FALSE) { // $filename holds the name of the file or folder // . and .. are "special" folder names that show up when you parse a folder // they mean . = "refresh" folder, ".." = go back one folder // so we ignore these two. if (($filename!='.') && ($filename!='..')) { // we only care about files, so ignore folders if (is_dir($folder_search.$filename)==true) { echo "skipping folder $filename ...\n"; } else { echo "copying $filename... "; // copy the file to destination folder, add .jpg to the end of whatever filename we have copy($folder_search.$filename,$folder_destination.$filename.".jpg"); echo "DONE \n"; } } } // we're closing the folder handle because we're done with it. closedir($folder_handle); } } ?>
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now