Copy Files from one folder to another folder - automationanywhere

I am reading the filename from the excel spreadsheet and iterating over the files present in a specified folder. If the file name in the folder matches with the filename in the excel sheet the message "Yes" is entered in the second column of the excel sheet otherwise "No" is entered. But when the filenames are not equal "No" is not shown in the excel spreadsheet it is left as blank. I am also trying to copy the files whose file names are matched to another folder but I am getting some error.

First thing, it would be more efficient and simpler if you use If file exists command.
If file exists ($filepath$) Then
Set Cell B$Counter$ = Yes
Copy file command
Else
Set Cell B$Counter$ = No
The error happened because you are looping on files on a folder and the counter is for the file loop not for the excel.

Related

How to output results to only 1 static excel file in Mapforce?

I am trying to check Log files for Errors and write the name of each file into an Excel register file.
Basically if I have 60 log files and 30 of them have Error I want to have 30 rows added to one excel file. And each time I run this mapping new rows to be added to that excel.
How can I do that? So far I have tried a couple of things, but none have actually done anything for me:
I have tried to specify the excel file in Outputfilename box, I added Sheet1 and the workbook name, but nothing.

Get FileName in SSIS

I'm new to SSIS, how can I get the Excel FileName that I'm trying to upload and assign it to a variable for later usage?
I've tried to do some research but I didn't get anything helpful.
Try using a Foreach Loop container:
Set the enumerator to Foreach File enumerator
Point it towards the folder where your excel file is located
tell it to look for .xls or .xlsx files
On Variable Mappings, create a variable called FileName
Obviously if you have more than one file in there, it will only give you the last file name.

Copy from CSV and Rename in MS-DOS

I have a .csv file with the following format:
<path_including_filename>,<new_filename>
<path_including_filename>,<new_filename>
<path_including_filename>,<new_filename>
<path_including_filename>,<new_filename>
I want to copy what's on column #1 in my CSV from Location A to Location B, then rename the file on Location B with the content of the column #2 in my CSV.
This is what I have done so far, the copying works but the renaming seems doesn't really happen:
For /F "tokens=1* delims=," %%i in (myCSV.csv) do (copy "%%i" "C:/myFolder" && rename "C:/myFolder/%%~nxi" "%%j")
Thanks in advance.
This answer used to contain my wrong suggestion from comments:
When the second column isn't a full pathname, but just a file name, rename "C:/myFolder/%%~nxi" "%%j" takes its destination argument as a path relative to current directory, not to the source directory.
I thought the problem should be solved by providing a full path name in the second argument of rename as well:
rename "C:/myFolder/%%~nxi" "C:/myFolder/%%j"
But no: the full path name is actually invalid in the destination argument for rename. The solution of cding to the target directory first and renaming without folder names in either argument turned out to work. I think that replacing forward slashes with backslashes in the first argument (leaving the second without the folder name) would help too: in my tests on Windows XP, rename failed with "file not found" when a source folder path contained forward slashes, and worked for backslashes.

Read data from External data sheet - eggPlant

Is there a way to read data from an external data sheet like excel, Text file etc. in eggPlant?
When running the same script for various set of Input parameters this would prove useful for me instead of hardcoding the values..
-Siva
Since this is the most viewed Eggplant question, I'll give it a more robust answer.
Yes! Using data from a data file is a fantastic way to parameterize your test without hardcoding!
Saving Data
To do so, you have to save your data in .csv or .txt format, within the Suite's Resources directory. This allows you to open and interact it from within Eggplant Functional.
Importing Data
In your script, you can reference these data files with just their filename, for example,
put ResourcePath("myData.txt") into FilePath
will save the entire file myData.txt from the Resources directory into a variable FilePath.
Accessing Data
You can then access each row of that file like any other file.
put line 1 of file FilePath into Name
put line 2 of file FilePath into DOB
If you save your data as a .csv, you can specify a row and column of a specific piece of data.
put item 2 in line 1 of file FilePath into Last_Name
Read more about reading files in the Eggplant Documentation!
For more complicated resource files, read this page in the Eggplant Documentation!
1. Enter the data in the excel sheet and save it as a CSV file.
2. Piece of code:
repeat with theData= each line of file "D:\TestData.csv"
log item 1 of theData
end repeat

Insert text into existing file

I have a txt file.how can I place some text among that and don't overwrite it? because when I use for example f.puts "aaaaaaaaaaaaaaa" Ruby overwrites my txt file .
thanks
You need to open it in append mode
File.open("file.txt", "a+"){|f| f << "aaaaaaaaaaaaaaaaaaa" }
Check out your previous question
File opening mode in Ruby
If you're asking how to insert text into the middle of an existing file, as below, you can't:
Original file first half, Original File second half
becomes:
Original file first half, Inserted text, Original File second half
You need to make a new file, copy the first half of the original into it, then write the new text, then copy the rest of the original file.
You've got to set the mode for the file when using open on a file.
There are more details here : http://www.ruby-doc.org/core/classes/IO.html#M000889

Resources