I want to copy one folder which has many sub folders to another directory/drive.I just don't want to copy one sub directory.This is what i am planning to do but with this i am getting an error except is not an internal or external command .
except "D:\Splunk\var" xcopy "D:\Splunk" "D:\test\Splunk_Withoutdata\%CurrentDate%\" /s
Thanks
VG
I have achieved it myself this is what i have done .I used Exclude command rather except .
xcopy "D:\Splunk" "D:\test\Splunk_Withoutdata\%CurrentDate%\" /EXCLUDE:D:\batch\list.txt /s
under list.txt I have mentioned the folder name which I want to exclude like var\.
Related
i started a project for a friend, that involved moving large quantities of files into specific folders. i was using automator as I'm handling the project on my mac, however automator does not have a feature to move section of files that are numbered numerically. for instance i will have files that are say "this file 100" and ill have 100 files like that. and then files that say "That file 50" and ill have 200 files like that. the project is splitting these files into there own folder but in section. so ill need "This file" 1-25 in one folder 26-80 in anther and so on. same is true for the "THAT FILES" but there isn't a pattern just the requirement my friend has asked for.
is there a easy way to write a script that could grab 1-25 or any sequel ordering with the same file name? because moving each file one at a time with automator has been taking to long.
thank you so much in advanced
I am not sure tu fully understand your naming convention, but overall , yes, with Applescript, you can move files into folders based on names, eventually adding sequence numbers.
Because I am not sure about your requirements, at least, here are some sample of syntax for main operations :
Get list of files with names containing xxx in folder myFolder :
Tell Application "Finder" to set myList to every file of myFolder whose name contains "xxx"
Then you have to do a repeat / end repeat loop :
Repeat with aFile in myList
-- do something here with aFile : example with name of aFile
end repeat
In that loop you can extract name, parse it, add a counter,...
To move file to new folder, you must use "move" instruction in a tell "Finder" bloc. Instruction "make" can also be used to create new destination folder based on name or root names of files. You must remember that Applescript commands will give error if same file name already exists in destination folder : Finder is able to add "copy" in the name, but you must do it yourself in Applescript.
Last advice if about the number of files to handle. If that number is not so high (less than few hundreds) Applescript is still OK for speed. If your number of files is much higher, then you must use either shell command or, better, a mix of AS and shell commands. The shell commands can be called from AS with a "do shell script". For instance, getting the list of 1000 files from a folder is time consuming with AS, but much quicker with 'ls' command ! Same for a copy. here is an example of copy using shell 'cp' :
do shell script "cp " & quoted form of (POSIX path of (aFile as string)) & " " & quoted form of (POSIX path of DestFolder) & (quoted form of newFileName)
Note : "Posix path" converts the AS file path (Users:myName:Documents:File.txt) into shell path (Users/myName/Documents/File.txt)
I hope it helps.
I am trying to launch a specific Excel document from the command line and pass in a variable in the form of a file path. On starting the Excel sheet runs a macro. This file path may contain spaces however when Excel interprets this it, I believe it tries to open up each section after a space as a new workbook. This results in a number of error warnings after the program runs as it obviously cannot file created from the substring.
The batch file looks like this
echo %~1
start excel.exe %USERPROFILE%\Desktop\Compare.xlsm /e/%1%
pause
EDIT: For Clarification. The batch file is activate when a file is drag and dropped onto it. The path of the file dropped is then stored in the %1 variable. If this file path has spaces then after each space Excel assumes that this is a new worksheet and tries to open it. The call to the Compare.xlsm which contains a macro that is going to use the path of the dragged file works correctly as it will always be on the desktop. My issue therefore is how to get Excel to take the entire path name stored in %1 and use it as one command line parameter rather than several calls to open new workbooks.
If the file that is used on the batch file does not contain any spaces then the errors do not occur. Is there any way of getting rid of the errors when using a file path that might have spaces e.g. C:\Users\My Documents\foobar.txt
Try this (TRIED AND TESTED)
echo %~1
start "excel.exe" "%USERPROFILE%\Desktop\Compare.xlsm" /e/%1%
pause
Notice the quotes around "Excel.Exe" and the file path?
Another example
echo %~1
start "excel.exe" "%USERPROFILE%\Desktop\Blah Blah.xlsm" /e/%1%
pause
I am assuming that you are running the code from a .Bat file
as Sid says, any paths that contain spaces must be quoted.
so to use a pth such as C:\My Documents\fubar.txt you would have this:
"C:\My Documents\fubar.txt"
and in your example:
echo
%~1
start excel.exe "%USERPROFILE%\Desktop\Compare.xlsm" /e/%1%
pause
EDIT:
When using a variable as the path, you need to include the quotes in the variable!
I used an excel template. In my ssis package at first the template is copied in the working directory and package execute. In the next run the excel file which is already existed in the working directory it moved into BACKUP folder and again the template file copied. It works good.
But i want to do something when i move it i want to rename it like is the previous file name is Input_01 in the next move it will input_02. How can i do this?
i am using Execute process task toolbox in SSIS pacakge.
and a .bat file is called. in the .bat file i write
move "E:\InputFolder\Input.xls" "D:\Backup"
copy "E:\Template\Input.xls" "E:\InputFolder\Input.xls"
I want a ouput in the backup folder the excel files are like
Input_01,Input_02.... what will be my command?
Here's how to do it with a batch file:
#echo off
set cnt=1
for /f %%f in ('dir /b "D:\Backup\Input_*.xls"') do set /a cnt+=1
if %cnt% lss 10 (move "E:\InputFolder\Input.xls" "D:\Backup\Input_0%cnt%.xls") else (move "E:\InputFolder\Input.xls" "D:\Backup\Input_%cnt%.xls")
copy "E:\Template\Input.xls" "E:\InputFolder\Input.xls"
You can have more control over your files' naming convention (not to mention deletion of old files) if you use a Script Task, though.
can we use a 'File system task' instead. It helps us Renaming a file. You will have to use a 'For-Each loop Container' as well.
I have a large amount of files to Rename based on User input variable and then copy to a specific location. Below is a sample of what I have thus far. It appears as though the Set /p is recognized in the Rename command by not when it goes to Copy it to the new dir. Any help would be appreciated.
#Echo OFF
Echo "Blahhh Rename and Copy. Press Enter."
Pause
SET /p SN=EnterServerName-
Echo You Entered - %SN%
Pause
Rename C:\ctemp\WorkingCSRs\key.pem %SN%_Key.bin
Copy C:\ctemp\WorkingCSRs\Certificates\%SN%_Key.bin C:\ctemp\WorkingCSRs\Certificates\folder /y
You're renaming in C:\ctemp\WorkingCSRs, but the renamed file is expected to be in C:\ctemp\WorkingCSRs\Certificates when copying.
Also you could do the copy as (assuming you don't need the file to be renamed):
Copy C:\ctemp\WorkingCSRs\key.pem C:\ctemp\WorkingCSRs\Certificates\folder\%SN%_Key.bin /y
I like to upload multiple files, with different names, in a single FTP task to server in SSIS package.
I am only able to upload one file.
the file names are also different e.g
xyz, zbc, ced
is there any way to upload multiple file in a FTP task in SSIS.
Thanks
just stumbled upon this and it was exactly what I was looking for. to elaborate on Faiz's answer:
create the Foreach Loop Container
edit "Collection" in the Foreach Loop Container
set the "Enumerator" to "Foreach File Enumerator"
select the Folder you want to check in
set "Files" to "." or whatever wildcard filter you'd like
select "Fully qualified" as the "Retrieve file name"
click "Variable Mappings" and create a variable named whatever you'd like
drop an "FTP Task" inside of the container
create an "FtpConnection"
click "File Transfer" and set "IsLocalPathVariable" to "True"
select your new variable under "LocalVariable"
set "Operation" to "Send Files"
set whatever remote parameters you'd like
That's it! The variable will automatically update itself with the full path+name of each file found, and then upload it.
Put all the files in the same folder. Use FTP task inside a ForEachLoop and update the connection string using an expression updated by the loop container. That will do the trick.