I would like to download from my Google Drive.
The folders structure is quite complicated. Here is the overview:
Parent Folder 1
--- Parent Folder 2
------ Parent Folder 3
--------- Parent Folder 4
------------ Parent Folder 5
--------------- Data
is there any script to download files with the folder structure like this:
Parent Folder 2
--- Parent Folder 3
------ Parent Folder 5
--------- Data
Thanks
I have done this in the past what you will need to do is create a recursive method. First get a list of all the files on your google drive account. Then sort them by the name if the file has a folder then create that folder. Then Find all the files within that folder and list them. You can preform a download once on the file once you have found the correct directory it should be in.
This is my example using C#.
public static void PrettyPrint(DriveService service, Google.Apis.Drive.v3.Data.FileList list, string indent)
{
foreach (var item in list.Files.OrderBy(a => a.Name))
{
Console.WriteLine(string.Format("{0}|-{1}", indent, item.Name));
if (item.MimeType == "application/vnd.google-apps.folder")
{
var ChildrenFiles = ListAll(service, new FilesListOptionalParms { Q = string.Format("('{0}' in parents)", item.Id), PageSize = 1000 });
PrettyPrint(service, ChildrenFiles, indent + " ");
}
}
}
My full tutorial on how to do this in C# can be found her List all files
Related
I am currently using bazel for my GoLang app.
container_image(
name = "my-golang-app",
base = "#ubuntu_base//image",
cmd = ["/bin/my-golang-app"],
directory = "/bin/",
files = [":my-golang-app"],
tags = [
"manual",
VERSION,
],
visibility = ["//visibility:public"],
)
Except my-golang-app folder I need to copy, while building this image, another folder named my-new-folder and everything in it.
How does one do that with bazel? I can't seem to find the solution in the bazel docs.
dockerfile {
run 'mkdir -p /usr/local/bin'
// add the lines below
add {
from 'docker/my-new-folder/'
into '/'
}
Use pkg_tar like the container_image docs reference. Something like this:
pkg_tar(
name = "my-files",
srcs = glob(["my-new-folder/**"]),
strip_prefix = ".",
)
container_image(
name = "my-golang-app",
files = [":my-golang-app"],
<everything else you already have>,
tars = [":my-files"],
)
pkg_tar has various options to control where your files end up, if you want something beyond just taking an entire directory. For more complicated arrangements, I find multiple pkg_tar rules for various directories linked together via deps a helpful pattern.
I am trying to create a sub-mailbox in Apple Mail using JavaScript.
I have the following code snippet (parent is a reference to the mailbox in which I want the new mailbox):
var mb = mail.Mailbox({name: "SubFolder"});
parent.mailboxes.push(mb);
The events log shows:
app = Application("Mail")
app.mailboxes.byName("Local").mailboxes.byName("Archive").mailboxes.push(app.Mailbox({"name":"SubFolder"}))
--> Error -10000: AppleEvent handler failed.
What am I doing wrong?
Thanks,
Craig.
Code now:
var mb = mail.Mailbox({name: "Local/Archive/Test Archive/SubFolder"})
logger.logDebug("mb = '" + Automation.getDisplayString(mb) + "'.");
mail.mailboxes.push(mb) // create the subfolder
This works as long as there are no spaces in the path.
I tried to force the space using \\ in front of it, but then you get "Test\ Archive" as the name.
So how do I get a space in the name to work?
Thanks.
To create a sub-folder, you need a name like a posix path --> "/theMasterMailbox/subMailBox1/subMailBox2/subMailBox3".
So, you need:
A loop to put the name of each parent folder into an array.
Use join('/') to join the elements of an array into a string.
Use mail.mailboxes.push(mb) instead of parent.mailboxes.push(mb)
Here's a sample script which creates a mailbox named "SubFolder" in the selected folder (the mailbox):
mail = Application('com.apple.Mail')
parent = mail.messageViewers()[0].selectedMailboxes()[0]
mboxNames = [parent.name()]
thisFolder = parent
try {
while (true) { // loop while exists the parent folder
mboxNames.unshift(thisFolder.container().name()) // add the name of the parent folder to the beginning of an array
thisFolder = thisFolder.container() // get the parent of thisFolder
}
} catch (e) {} // do nothing on error, because thisFolder is the top folder
mboxNames.push("SubFolder") // append the name of the new subFolder to the array
mBoxPath = mboxNames.join('/') // get a string (the names separated by "/")
mb = mail.Mailbox({name:mBoxPath})
mail.mailboxes.push(mb) // create the subfolder
I have a shared folder and one of the editor usually add files into it. I want to keep flushing the folder by the following code by capturing its last change date. Its throwing error and it seems to me that as i am NOT the owner of the file, i cannot able to delete. Is there any way out?
function 7DayFlush()
{
// Log the files names and its last change info for the mentioned folder (by id)
// Enter the ID between Bracket
var mfolder = DriveApp.getFolderById('<i keep folder id here>');
// Following will get files from the folder.
var lfiles = mfolder.getFiles();
while (lfiles.hasNext()) {
var file = lfiles.next();
if (new Date() - file.getLastUpdated() > 7 * 24 * 60 * 60 * 1000) {
//Following will delete the files which matches the above condition which is older than 7days in the specified folder.
Logger.log(file.getName()+'----'+file.getLastUpdated());
//here is the error comes up.. help me.
file.setTrashed(true);
//here is the error comes up.. help me.
}
}
}
I'm implementing a Basic Folder Object for a namespace extension composed by folders and subfolders (the junction point is a filesystem folder, which is empty). I've implemented IShellFolder, and support returning IContextMenu in ShellFolderImpl::GetUIObjectOf.
Suppose that I have the following folders (where A and A\B are "virtual" folders fabricated by IShellFolder::EnumObjects)
C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}
C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}\A
C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}\A\B
I'm able to open C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}, and it lists the folder A. When I double-click (or select Open from context menu) on folder A, that folder is opened and subfolder B is listed in the view.
Problem: that only works for folders directly under C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}. The context menu is not displayed for subfolder B (and GetUIObjectOf is never called, even though IShellFolder:Initialize is called with the right PIDL).
In the relevant part of IContextMenu::InvokeCommand, I open the subfolder by doing
SHELLEXECUTEINFO sei = { 0 };
sei.cbSize = sizeof(sei);
sei.fMask = SEE_MASK_IDLIST | SEE_MASK_CLASSNAME;
sei.lpIDList = pidl; // the fully qualified PIDL
sei.lpClass = TEXT("folder");
sei.hwnd = pcmi->hwnd;
sei.nShow = pcmi->nShow;
sei.lpVerb = cmd.verb.w_str();
BOOL bRes = ::ShellExecuteEx(&sei);
DeletePidl(pidl);
return bRes?S_OK:HR(HRESULT_FROM_WIN32(GetLastError()));
Hi I have A local database named Database1.sdf.
I´m accessing it with following code to insert some data into a table:
public string DoLocalDbCmd(string Command)
{
int NumeroAffetto;
string ConnString = #"Data Source=|DataDirectory|\Database1.sdf";
SqlCeConnection Conn = new SqlCeConnection(ConnString);
SqlCeCommand Comando = new SqlCeCommand(Command, Conn);
Comando.CommandType = System.Data.CommandType.Text;
try
{
Comando.Connection.Open();
NumeroAffetto = Comando.ExecuteNonQuery();
return NumeroAffetto.ToString();
}
catch (Exception ex)
{
return ex.Message;
}
finally
{
Comando.Connection.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
DoLocalDbCmd cmd = new DoLocalDbCmd();
string cmdex = cmd.RunSqlCmd("insert into TBL_PROVA (BELLO) VALUES ('VERO')");
MessageBox.Show(cmdex);
}
The execution of code happen without errors, I retrieve the number of affected row = 1.
But after if I query the database there is not inserted no row.
Somebody can suggest to me what can be wrong ?
Thankyou in advance
Piercarlo
It is a common scenario when these conditions are all or partially present in your project.
You have a connection string with the DataDirectory substitution
string.
You have a connection on the Server Explorer that point to an SDF
file located in your project directory.
You have the property Copy To Output Directory set to Copy Always
on your SDF file listed in your project items.
When you run the program inside the IDE of VS the SDF file present in your project folder is copied to the Output Directory (BIN\DEBUG) following the setting of Copy To Output Directory and this could result in the overwriting of the file eventually already present in BIN\DEBUG.
You run your code and insert correctly your data into the file in the BIN\DEBUG folder.
You stop your program and checks if the record is present using the Server Explorer and you don't see any new record because you are looking at the file in the Project Folder.
You start a new debug session and the file in the BIN\DEBUG is overwritten again with the empty one.
So... change the property Copy to the Output Directory to Copy Never to stop this copying, change the connection in the server explorer to point to your database in the BIN\DEBUG folder (Or add another one keeping the old one for schema changes and the new one to verify your DML operations)