Azure data factory name output folder as the current timestamp - azure-data-factory

I am running a copy activity and I am trying to place the output file in a folder that is named after the current the timestamp. I am using utcnow('G') so I get the 10/21/2020 1:30:45PM. But when I run it it puts the file within 3 nested folders like this 10 / 21 / 2020 1:30:45PM/ file. It splits the date to make the month its own folder, the day its own folder within that, and the year and time its own folder within that. I am completely dumbfounded on why this is happening. Obviously I just want a single folder. How do I fix this?

This is because utcnow('G') contains '/'. When you have '/' in your folder path, this means you have sub folder. So you will create three folders:10,21 and 2020 1:30:45PM. If you only want a single folder, you can replace '/' to other character like '-'. Or just use other date format which not contains '/',such as 'utcnow('o')'.More detail,you can refer to utcnow() function https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions#utcnow.

Related

Batch file to move a download to new folder

I used the tampermonkey extension to download an excel file every time I visit a certain URL. I want to write a batch file that will visit that URL everyday, cause the file to download, and then move that downloaded file into a new folder.
I know how to get to the url and initiate the download with a batch script
The downloaded filename is in the format "websitename_DDMonYYY," except if the date is 1 digit the leading zero is removed.
For example, today's downloaded file would be "websitename_8Feb2023"
How can I write a script that will match the downloaded file name to today's date, so that I can then move it to a new folder?
I've been trying to use the %date:~#,#% syntax to extract the day, year, and month, but I need help removing the leading zero in the date, converting the month number into a 3 letter code, and then concatenating all of these into a single string.
Thank you!

How to copy file based on date in Azure Data Factory

I have a list of files in a adls container which contain date in the name as given below:
TestFile-Name-20221120. csv
TestFile-Name-20221119. csv
TestFile-Name-20221118. csv
and i want to copy files which contain today date only like TestFile-Name-20221120. csv on today and so on.
I've used get metedata activity to get list of files and then for each to iterate over each file and then used set variable to extract name from the file like 20221120 but not sure how to proceed further.
We have something similar running. We check an SFTP folder for the existanc e of files, using the Get Metadata activity. In our case, there can be folders or files. We only want to process files, and very specific ones for that matter (I.e. we have 1 pipeline per filename we can process, as the different filenames would contain different columns/datatypes etc).
Our pipeline looks like this:
Within our Get Metadata component, we basically just filter for the name of the object we want, and we only want files ending in .zip, meaning we added a Filename filter:
:
In your case, the first part would be 'TestFile-Name-', and the second part would be *.csv'.
We then have a For Each loop set up, to process anything (the child items) we retrieved in the Get Metadata step. Within the For Each we defined an If Condition to only process files, and not folders.
In our cases, we use the following expression:
#equals(item().type, 'File')
In your case, you could use something like:
#endsWith(item().name, concat(<variable containing your date>, '.csv'))
Assuming all the file names start with TestFile-Name-,
and you want to copy the data of file with todays date,
use get metadata activity to check if the file exists and the file name can be dynamic like
#concat('TestFile-Name-',utcnow(),'.csv')
Note: you need to fromat utcnow as per the needed format
and if file exists, then proceed for copy else ignore

How to move file into another directory which have current date and time stamp (YYYY-MM-DD_HH-MM) in shell

I want to move one file from one folder to another. Another folder is randomly generating with date and time stamp at run time in YYYY-MM-DD_DD-MM format. The code is given below. I need to give path of current timestamp in this YYYY-MM-DD_DD-MM format.
Written Some Code for same
# Command to execute
execute_cmd=mv
path=/home/centos
# Files inside actual_dir has to be moved
actual_dir="$path/Input_File"
# This is the directory where files will be moved and kept
backup_dir="$path/Archive/{$Here I want to write some code so that I can move into one particular folder with date and time stamp YYYY-MM-DD_DD-MM} "

MatLab - accessing subfolders of folders saved as variables

I have the following code which can create a directory within a selected folder:
photos_dir = 'C:\Users\Bob\Photos';
mkdir(photos_dir,'Christmas 2015')
I'd like to then be able to save an image to this folder, I think using something like:
imwrite(img,Christmas 2015,'jpg')
However, this does not select the "Christmas 2015" folder which is in the "\Photos" directory. How can I make the image be written to this location?
First of all, you're going to have a syntax error since Christmas 2015 should at least be a string. But other than that, if you want to save a file in a particular location (other than the current working directory), you need to provide the full path to the file location.
To do this, you need to use fullfile to combine all of your directory and file names together into a full file path.
image_name = fullfile(photos_dir, 'Christmas 2015', 'yourphoto.jpg');
imwrite(img, image_name, 'jpg')

MATLAB: How do I copy files with a specific extension to a folder one directory above it?

I am trying to copy specific files from one folder into another folder one directory above it. I want to do this for all of the folders I have at once. Here's my file structure:
201415ContinuousForDropTeqc/StationA/201411/
This path has 25 folders labeled 5 through 30 (representing days).
In each of these 25 folders there are 3 folders named 'dat', 'RAW', 'rinex'.
I want all files ending in .14o from the RAW folder (there are many other file types in this folder as well) to be copied to the rinex folder.
I'm also hoping I can find a way to repeat this for every day in the 201411 folder. This last part isn't critical since I think can type the path manually and just run the script that copy and pastes the files I want.
I hope this was clear. I'm new-ish to MatLab.
Thank you in advance for your help!
Tiffany
You can do all that using the dir command. Check this link.
You can use it twice. first to get all the 25 folders and then to get all the files within the folder.
Days = dir('201415ContinuousForDropTeqc/StationA/201411/');
for k=3:numel(Days) %notice the 3
files = dir([Days(k).name '/RAW/*.14o']);
for n=1:numel(files)
copyfile([Days(k).name '/RAW/' files(n).name],[Days(k).name '/rinex/' files(n).name]);
end
end