So what i'm trying to do is get a selected file from File explorer, and copy it then paste it into a new folder via a batch file upon clicking it....is there a way?
One way I can think about you doing that is by creating a some sort of data base thing
For Example
#echo off
:fileSelect
echo Which folder do you want?
set /p folderName=
goto %folderName%
You can do it that way. Then you will have to manually put in the locations the files like so
:"Files Name here"
copy C:\"Files location" C:\"Designated location to paste file"
goto fileSelect
That's one simple way of doing it. If that's not exactly what you want or if its unclear let me know and I will attempt to help you find another way to do it.
Related
I have the following batch code
copy H:\test\Folder\sample.ini H:\test\sample.ini
Pretty straight forward. However, it doesn't work if I modify the code to look in "New Folder" instead of "Folder".
In other words, I get a "file cannot be found error" if the directory structure contains a space. How can I resolve this?
it Doesn't work because there is a space in your Directory name(i.e New Folder) and it confuses windows interpreter,so all you have to do is add "" around your path.the following code should do your job:
COPY /Y "H:\test\New folder\sample.ini" "H:\test\sample.ini"
I use Autohotkey to replace some of the broken buttons on my mouse and to have an auto clicker and other quality of life hotkys and such, I have them in a folder with a batch file. I would like the bat file to open them all without having to type the names of the scripts one by one, sort of having an 'all' character like *.ahk. Is this possible?
I'm not completely sure I got the question , but if you want to run all .ahk files you can use something like this:
for %%a in (*.ahk) do start "" "%%~fa"
I'm a Mac user, but I need to write a script on Windows, and I'm not sure how I should go about that.
Here's the scenario:
Someone adds photos to a USB drive. The drive is then inserted into a digital picture frame.
In order for the photos to autoplay, a 'playlist.asb' file must be present on the drive. I want to create a script that can be clicked on and executed to auto create the playlist file based on the image files added to the USB. The script would do something like this:
Check if there are images in the 'slideshow' folder.
Check if file called 'playlist.alb' exists, if not create it. If so, overwrite it.
Loop through available images.
Add each image name and extension on a new line.
Save (and overwrite any existing playlist file) and exit.
I'm comfortable with AppleScript for Macs, but I'm not sure if a Windows equivalent would make sense, or if some kind of command line script would work better.
Any help is greatly appreciated.
Something like this should do it:
#echo off
setlocal
cd /d %~dp0Slideshow
if exist playlist.alb del playlist.alb
for %%a in (*.jpg *.gif *.png) do (
echo %%~nxa>>playlist.alb
)
I am completely new to this, but I am trying to create a .bat file that will allow me to rename a pair of files within a designated folder and move them into a subfolder. The part I am having trouble with is that I am wanting a prompt to come up to identify/select the files to be renamed and moved.
Example file names are:
A1234, A1235, A1236, B1234, B1235, B1236, etc.
Is there a way to bring up a prompt that allows the user to type the shared name (ex 1234)of the files and rename and move both files to the designated subfolder?
Any and all help would be appreciated!
Suggested approach
for part of problem
part I am having trouble with is that I am wanting a prompt to come
up to identify/select the files to be renamed and moved. Is there a
way to bring up a prompt that allows the user to type the shared name
(ex 1234)of the files and rename and move both files to the designated
subfolder?
Do a search operation using wildcard, like "?1234" for the case highlighted above ( should be made generalized for all acceptable and expected patterns "*1234*" is the generic most )
Now do a RENAME inside a For loop on the results obtained by search.
As you suggest you are a newbie with Batch, following tutorials will help you build your file. Look for elements like Variables, For Loop
Batch Tutorial
Here you go
#echo off
set /p file=Please type shared name:
for %%a in (C:\Folder\?%file%.*) do (
move "%%a" subdir
ren "subdir\%%a" newname.*
)
I'm have a lot of pictures in a file system. I'm trying to figure out a way to rename all of the files, and if possible put them in one folder. At the very least rename them where they are.
They are currently in a hierarchy like this:
folder1\folder2\filename.jpg
Is there any way I can write a script to rename the files so the name of the actual file would be:
folder1-folder2-filename.jpg
I'm not sure how to go about this. Any suggestions or a push in the right direction would be greatly appreciated.
try this..
for %%* in (.) do set name=%%~pn*
set name=%name:\=-%
set name=%name:~1%
%name% now has the folder name. add this to your file name.