Is it possible to create a text file and place it in an existing file using Batch? What I mean is when I type echo %input%>document.txt it obviously saves it as a text document, but what I want to happen is for it to automatically place that text document into an existing file that I have previously created. Do I have to call the folder name? I'm honestly lost on how to do this. Any help would be great!
Instead of doing
echo %input%>document.txt
You can specify the entire path of the text document
echo %input%>C:\path\to\document.txt
Obviously you need to change the path to be whatever you want.
Related
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.
I have a batch file that creates text files in multiple folders.
What I need it to do as well, is after creating that text file, save a copy of it as a .scr file
If I were to do with this without a batch file, I would open the text file, click SAVE AS and save the file with a .scr extension. I cannot figure out how to add this feature to my batch file however.
The original text file cannot be erased, so I can't just change the extension. I would have to copy it, then change the extension, or imitate the SAVE AS feature.
Help?
I just used the ren *<> *<> command. It is extremely redundant because I end up making two text files that are identical and just changing one, but it gets the job done
I felt it was better to ask this separately rather than expect an answer from my comment on my previous post.
I already have variables set for the directory number %jobn% which is unique is there a way I can search for the unknown element to add to another variable, I know via the command line I can run Dir D09854* and I will get a single report with the full name, can this be collected somehow and add to a named variable?
S:\SWDA\HBOS>dir d09854*
Volume in drive S is Images
Volume Serial Number is FE8F-38FE
Directory of S:\SWDA\HBOS
18/02/2013 10:29 <DIR> D09854_Parent Test
I want to add the elements after "_" to a variable %DirDesc% so I can create the full path by combining %jobn%%DirDesc% to get "D09854_Parent Test"
dir d09854* /b will recover the full folder name in one line, without the extra cruft, if that's any use? What are you writing this widget in?
Does it have to be Good Old Fashioned DOS, or can the newer Command extensions be used?
With limited old DOS, I can't think of a way to get that into a SET Variable without piping it to a temporary batch file, having first ECHO'd a set variable= into it, and using >> in the pipe to append to it... and then CALL the temporary batch file to execute the command!
I was trying to put together a .bat file program that presents readable information. Basically, we have a application called vSphere that reads custom scripts directly from a xml file. So there are xml elements that are passed into the the client. Now, I have a similar situation where we are doing the same thing with vCloud. The difference is that vCloud only reads data from a .bat file instead of a xml file.. If I wanted to do such a thing what would that look like.. Below is my psuedo code as I'm not completely familiar with .bat file syntax. Is this how I can present the information to be read by the vCloud client? The client already knows how to read the .bat file, I just need help with a control structure example of a .bat file to tackle this problem.
xml version:
<_type>viss.CustomizationExample</_type>
<changeExample>1341932956</changeExample>
.bat file version:
#echo off
SET ChangeExample=1341932956
if changeExample==""(
echo changeExample==ChangeExample
)
Thank you!
this code may work for you
#echo off
set changeExample=1341932956
echo %changeExample%
This will display the value of changeExample 1341932956 on the cmd screen if you run the batch file is this what you wanted...
Your almost there, just a couple of things.
To access a variable after setting it, without any special circumstances, you need to put %'s at each side of it to tell cmd that you want the value contained in it.
By default if is case sensitive, so you must first make sure that your variables are spelt
correctly, also you need a space between the end of the if condition and the bracket.
Provided that this is the correct format for the batch (I don't have a clue what it actually wants to read) then this is the correct syntax
#echo off
SET ChangeExample=1341932956
if %ChangeExample%=="" (
echo changeExample==%ChangeExample%
)
I presumed you wanted to echo the variable contents rather than the string ChangeExample, if you just want the string remove the %'s.
I have the code below to set a variable in Applescript for the path to the iTunes Music Folder:
set username to text returned of (display dialog "RingtoneDude" default answer "Enter your path to your iTunes Ringtones folder here. e.g. /Users/David/Music/iTunes/iTunes Music/Ringtones" buttons {"Confirm", "Cancel"} default button 1)
And then I have the code to call the variable username to copy a file
tell application "Finder"
copy file theCopy to username
end tell
but the file theCopy which is on the desktop (theCopy is a variable) does not move to the folder.
Please help.
I believe you've misunderstood the copy command. The copy command is used for transferring the contents of one variable into another variable. What you need to use is the duplicate command, which is used for copying files to a specified location. Its syntax is as follows:
duplicate [alias] to [alias]
[replacing boolean] --If true, replaces files in the destination with the same name
Having said that, your new code, in conjunction with Uriah Carpenter's answer, should look something like this:
set myRingtoneFolder to choose folder with prompt "Select your iTunes Ringtone folder:"
tell application "Finder" to duplicate theCopy to myRingtoneFolder
I would suggest you use choose folder which returns an alias.
To make some text into an alias object use set myAliasPath to myTextPath as alias.
For more detailed information see Aliases and Files in the AppleScript documentation.