I am writing a SSIS package, and at one point I am working with a certain folder that I know the path for, and need to delete a folder inside that, but I don't know the name (path) of the inner folder.
So for example, I know this path: C:\Known, but there will be a folder inside 'Known' that I would like to delete. Like C:\Known\ Unknown
I can't use a File System Task and delete the unwanted folder, because I don't know the name of the folder, and I can't use a File System Task to delete all the directory contents of 'C:\Known', because it also contains .jpeg files that I need to keep.
Any thoughts? A solution to get the name of the Unknown folder, or delete any folders inside 'C:\Known' is acceptable.
You can add this code to a Script Task to delete all subdirectories in a path while not deleting any other file types:
foreach (string subdirectoryPath in Directory.GetDirectories(knownPath, "*", SearchOption.AllDirectories))
{
Directory.Delete(subdirectoryPath);
}
Related
my question is how we will create SSIS package to get the particular file from multiple files and copy to different folder
Need Help
You can use File System Task in your package control flow.
Configure the properties as below:
DestinationConnection: Enter the full file path of the folder you want to move your file to e.g c:\Users\ToTest
Operation: Change to Move file.
SourceConnection: Enter the full file path of the folder where your file is, including the file name and extension e.g c:\Users\Test\testfile.csv
You'll need at least two components.
Use a Foreach Loop container with the default Foreach File Enumerator on the Collection tab. Set Folder: to \YourFolder and build an expression under Files: to identify the particular file you're interested in.
Inside the Foreach Loop container, add a File System Task to Copy the file from the Source folder to the Destination folder.
I want to find files that includes some keyword and copy it to other folder.
So I need two features.
Find files by keyword and list it at "file" type value.
copy the file to different directory.
But Google drive supports same folder name so I don't know how to targeting folder by name. And I want copy the file only if there is not file has same name. Because I'll run this script every 5 minutes and if I don't set about that, there are many same name files to target directory.
How can I do this?
AFAIK, the only supported methods that you can use to get files in Class DriveApp are:
getFileById(id)
getFiles()
getFilesByName(name)
getFilesByType(mimeType)
Then, to make a copy to other folder, you can use the following methods that are given in Class File
makeCopy(destination)
makeCopy(name, destination)
Lastly, the suggested solutions given in this SO post might also help.
I have a process that I want to create in SSIS. What I have so far is below.
So the scenario is that a number of different file types are downloaded to a specific location - which has been created as a variable "RootFolder"
Within that RootFolder, is a folder called "Archive"
The first part of the process is to create a folder within the variable of ArchiveFolder, which is basically todays date.
Then in a For Loop Container, it copies all the files in the RootFolder to the Archive Folder. So we have a history of the files received.
The next step that I want to carry out in SSIS is to add a header line at the top of each of those text files. So all the files that still exist in the Root Folder get a header added to the top of the file. Is there something direct in SSIS to do this, or would I need a .bat file to do it and have an Execute Process Task, to call that bat file. Either way I have no idea how to achieve this bit. Your help will be appreciated.
All my projects contains alot of files with the same name 'file1.php file1.less file1.css file1.min.js file1.js file1.json'
Is there a plugin or a way to group all those files with same basename under eg. file1.php, just like the filewatchers does it.
The grouping relations can only be established when running watchers, so using watchers is the right way to go. It can indeed be a batch script that does nothing - this is the 'Output paths to refresh' option that matters: it should provide a pattern for files that has to be nested. For example, let you have same-named files with .php, .css and .js extensions in some folder, and like to nest the latter 2 in .php file (doesn't make much sense, but it's just an example).
create a .bat/sh file that does nothing (echos some string, etc.)
create a new custom file watcher, set 'php' as file type, your .bat - as a program
specify $FileName$ and $FileDir$ as 'Arguments' and 'Working directory' respectively
set $FileNameWithoutExtension$.css:$FileNameWithoutExtension$.js as 'Output paths to refresh'
Now when you modify your phpfile watcher will be run and nest .js and .css in .php
Currently it is not possible to perform such nesting/grouping manually (excluding File Watchers).. and I personally know no plugin that can do this.
Watch these tickets (star/vote/comment) to get notified on progress:
https://youtrack.jetbrains.com/issue/IDEA-113347
https://youtrack.jetbrains.com/issue/WEB-7635
In my script I have template docs in the main drive, but when the copy is created and populated with my excel data, I want it to be saved in a folder in drive. I have the script do that, but it has one copy of the file in the Main Google Drive, and the other in the folder I want it in. If I delete one of the copies, it deletes both.
Is there any way I can have it save automatically in the specified folder without also being in the main drive folder?
Folders in Google drive are not exactly like forders in a computer : having the file in your 'root' folder and in another folder doesn't mean there are 2 files, but rather 1 and only file with 2 labels... that's why you can't delete one without deleting the other !
The solution is simply to play with these labels in the script, here is how it works : (I commented each step to make it clear.)
function othertest(){
folder=DocsList.createFolder("MyFolder"); // or getFolderById or whatever other way to get your target folder
var file=DocsList.createFile('File2', 'Empty');// just an empty file for test but this would be your file copy that you want to "move"
file.addToFolder(folder);// put it in the folder
file.removeFromFolder(DocsList.getRootFolder());// and remove from the root
}
The other possible solution is to create the file directly in the target folder since the folder object supports the createFile method. (Not sure though that you can do it in your specific use case)
here is an example, you can see that the file is not in the root folder.
function createFileinFoldertest() {
var folder = DocsList.getFolder('test')
folder.createFile('Empty test fileName','nothing in there')
}