w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Bash script to find file older than X days, then subsequently delete it, and any files with the same base name?
I doubt this can be done cleanly in a single pass. Your best bet is to use -mtime or a variant to collect names and then use another find command to delete files matching those names. UPDATE With respect to your comment, I mean something like: # find basenames of old files find .... -printf '%f ' | sort -u > oldfiles for file in ($<oldfiles); do find . -name $file -exec rm; done

Categories : Bash

Batch script to delete files older than X days (based on creation date, not modified date)
See if this helps - Keep the 5 *.config files (skip=5) with the most recent creation date Test it on sample files. @echo off pushd "d:folder" del file2.tmp 2>nul for /f "delims=" %%a in ('dir *.config /b /a-d ') do call :getcreationdate "%%~fa" sort /r <file2.tmp >file.tmp for /f "skip=5 tokens=1,*" %%a in (file.tmp) do del "%%~b" del file.tmp file2.tmp popd pause goto :EOF :getcreationdate set "file=%~1" set "file=%file:=\%" WMIC DATAFILE WHERE name="%file%" get creationdate | find "." >file.tmp for /f %%b in (file.tmp) do set dt=%%b set dt=%dt:~0,8%_%dt:~8,6% del file.tmp >>file2.tmp echo %dt% "%~1"

Categories : Windows

Batch file to delete subfolders in directory if all files is older than 3 days
This uses a VBS script to calculate the date 3 days ago, and then checks if any files are younger than that, using xcopy, and if no files are younger than 3 days then it should remove the "C:UsersMahmo03SShabanAnsys" folder and subdirectories. 3 days is a date calculation and not exactly 72 hours. It's not tested. @echo off call :date today -3 echo mm-dd-yyyy 3 days ago was: %day% xcopy "C:UsersMahmo03SShabanAnsys*.*" "%temp%" /l /s /d:%day% |find ":" >nul if %errorlevel% EQU 1 rd /s /q "C:UsersMahmo03SShabanAnsys" goto :EOF :date set date1=%1 set qty=%2 set separator=%~3 if /i "%date1%" EQU "TODAY" (set date1=now) else (set date1="%date1%") echo >"%temp%\%~n0.vbs" s=DateAdd("d",%qty%,%date1%) echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_ echo>>"%temp%\%~n0.vb

Categories : Windows

Run a batch file that would delete files in a folder (and its sub folders) that are older then 30 days
I did some copy and paste for you from here: forfiles -p "C:whatever" -s -m *.* /D -30 /C "cmd /c del @path" See forfile documentation for more details.

Categories : Windows

How do I move files older than 30 days?
Use robocopy in a batch file for this kind of task: @echo off robocopy D: E: /mov /s /minage:30 Don't waste your time on trying to re-invent robocopy in VBScript.

Categories : Vbscript

Display the list of files using Google Drive SDK API in Java
You must set ServiceAccountUser as the user's drive you wanna access, and ServiceAccountId as the Service Account User something like this: GoogleCredential credentialUser = new GoogleCredential.Builder().setTransport(httpTransport) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(SERVICE_ACCOUNT_EMAIL) .setServiceAccountUser("user@gmail.com") .setServiceAccountPrivateKeyFromP12File(new File(SERVICE_ACCOUNT_PKCS12_FILE_PATH)) .setServiceAccountScopes(serviceAccountScopes).build();

Categories : Java

calculate total used disk space by files older than 180 days using find
du wouldn't summarize if you pass a list of files to it. Instead, pipe the output to cut and let awk sum it up. So you can say: find . -mtime +180 -exec du -ks {} ; | cut -f1 | awk '{total=total+$1}END{print total/1024}' Note that the option -h to display the result in human-readable format has been replaced by -k which is equivalent to block size of 1K. The result is presented in MB (see total/1024 above).

Categories : Linux

Upload text file to Google Drive with Google Apps Script
To do a file upload, you cannot use a server handler. You must use a FormPanel and a Submit button. See the FileUpload widget's documentation.

Categories : Javascript

How to edit the document after uploading it on google drive using Google Apps Script
Currently, when you upload a document/spreadsheet using Apps Script, it is uploaded in the same format i.e. it is not converted to Google Docs format. There is an open issue asking for this feature. You can star the issue to register your interest.

Categories : Google Apps Script

Is it possible to Use Google Apps Script to check condition in Google Drive Forms?
Google Forms does not support client-side validation like that, at this time. Deploying an Apps Script as a web app would allow you to do it, but you have to create all of the formatting and functionality yourself. The recent inclusion of data validation functions in Apps Script in conjunction with Google Forms supporting some scripting access means that we could see something along these lines in the future. Would certainly go a long way toward making Google Forms more useful.

Categories : Google Apps Script

Google drive: Get (root) file and folders with javascript api (get only deleted files on drive)
Same situation as following question: google drive api, javascript list files returns nothing I needed to add to the scope the path 'drive' at authorizing, I had only drive.file which is intent to create/edit files only. The weird thing is that the API returns deleted files when you don't have permissions to view files, I think it's a bug in the API (a serious one). Post this bug on google drive: https://productforums.google.com/forum/#!searchin/drive/security$20issue$20permission$20view/drive/pupjKxTz9FU/cUarGIl_Ah0J

Categories : Javascript

google drive api - copyfile working only with permission for accessing all files in drive (but jst need to copy)
According to the documentation, Files.copy() requires at least one of the following three permissions: https://www.googleapis.com/auth/drive: "View and manage the files and documents in your Google Drive" which is the one you want to avoid https://www.googleapis.com/auth/drive.file: "View and manage Google Drive files that you have opened or created with this app." Which means you can freely create any file but only open the files your app created. You can only copy a file you created, but you cannot copy any other files even if it is public. https://www.googleapis.com/auth/drive.appdata: "View and manage its own configuration data in your Google Drive" Which only lets you control your application-specific Appdata folder which is probably not what you want. You can only copy a file with

Categories : Javascript

Error while Retriving files from google drive using drive API. “Calling this from your main thread can lead to deadlock
You should do any code that could take a long time such as I/O or network activity on a different thread. In your situation your file retrieval would be best done within an ASyncTask. The reason for this warning is because when your code is being executed to retrieve the file from Drive, the code will block until the file retrieval has completed, this means that nothing else within the program will be able to respond, i.e. GUI will not update and input from the user trying to do stuff with the GUI will not be registered. After a few seconds, if the file retrieval still isn't complete, then the user will be presented with an ANR (Application Not Responding) message. This will either give the user the choice of waiting, if their patient, or most likely force closing your app.

Categories : Android

Delete files older than X minutes
When used with -mmin, -daystart appears to make it calculate from the end of today, not the beginning. If you just want to find files modified more than 59 minutes ago, you don't need that option. -mmin calculates from the current time by default. barmar@dev:~/testdir$ date Sat Jul 20 10:02:20 CDT 2013 barmar@dev:~/testdir$ ls -l total 0 -rw-r--r-- 1 barmar adm 0 Jul 20 09:57 a.txt barmar@dev:~/testdir$ find . -maxdepth 1 -mmin +2 -type f ./a.txt barmar@dev:~/testdir$ find . -maxdepth 1 -mmin +10 -type f

Categories : Linux

Monitoring changes in Google Drive files for whole domain using Drive API
Domain-wide delegation simplifies the authentication portion for your app but you'll still need to auth as each user to get their files and changes. It may be possible for your app to "grab" all files and make itself (or a special user) the owner, then you just have one user account to scan but the "grab" process would still need to run at regular intervals to find new files created or uploaded by end users. I believe most apps that need to scan content at this level do it via cron jobs or AppEngine task queues which make it easy to chunk up the scans throughout the day. Generally they expect to scan each user account once every 24 hours or so.

Categories : Google App Engine

How to create two days AllDay Event with Google Apps Script?
You need to use createAllDayEventSeries(), which accepts a Recurrence parameter. var recurrence = CalendarApp.newRecurrence().addDailyRule().times(2); var eventSeries = CalendarApp.getDefaultCalendar().createAllDayEventSeries('My All Day Event', new Date('June 28, 2013'), recurrence, {guests: 'everyone@example.com'}); Logger.log('Event Series ID: ' + eventSeries.getId());

Categories : Google Apps Script

How to use Google Drive File Picker with Apps Script HTML Service
Unfortunately it isn't possible to use it in HtmlService, due to Caja restrictions. We're working on enabling it, but it may take some time. Edit As of March 2014 this is now possible. See this page for sample code.

Categories : HTML

MySQL PDO delete users older than 2 days, delete content from other tables with user_id
Ideally, you'd define things with a FOREIGN KEY constraint, and define an ON DELETE CASCADE, which automagically will delete all that related data for you. If that's not possible for some reason (stuck with a MyISAM table for instance), you could simply JOIN the related tables (yes, you can delete from more then 1 table at once). If it's your first time doing that, do it on a testdatabase, and certainly not in production.

Categories : Mysql

Google Drive SDK - JavaScript : How to list SHARED FILES (not shared with me)
If you're looking for all owned, shared files without knowing who they are shared with, you'd need to use a search query of 'me' in owners and then further filter down the list based on which returned files have shared: true set.

Categories : Javascript

Need Apps Script to Copy a File(s) from my Local Hard Drive to a Google Sites Folder
You have to write an UI to that allows the visitor to the site to upload the file. See https://developers.google.com/apps-script/reference/ui/file-upload for an example.

Categories : Google Apps Script

If user dosen't have Google Drive authority, Google Apps Script couldn't get active user email with "Session.getActiveUser().getEmail()"
It depends on who has access to your app - is it you alone, anyone or anyone, including anonymous. If it is set to anyone or anyone, including anonymous, have you logged in to your gmail account when you visit the google site.

Categories : Google Apps Script

How to get Public Url of the Google Drive Files?
From google-api-objectivec-client go to DriveSampleWindowController.m, check the method called - (void)downloadFormatSelected:(NSMenuItem *)menuItem where its shown cleary how to format the exportLinks. NSLog(@"%@",[file.exportLinks JSONValueForKey:@"urtitlekey"]); This is what you wanted.Hope it helps.

Categories : Iphone

Saving Files to Google Drive
Yes, if you set up a common Drive account and use Drive API such as Files.insert(), you can let user upload file without login. Actually, there is a quickstart for php which does almost same thing for you. You may want to start from this quickstart to upload a file from your server to Drive and integrate it with form to let any users upload file to your Drive.

Categories : PHP

Share files with Google Drive SDK
I am running into exactly the same issue. My app is requesting the full drive scope (so the app should have access to all files). But sharing only works if the file has been opened by the user from the drive before. There seems to be some magic "while-listing" of files that have been opened from drive. When accessing a file that has not been opened from drive before I get... Refused to display htps://drive.google.com/share?id=0534534543iTEhYamxfUnc2MnM&foreignServi…ent=postMessage&appId=46459361793&embedOrigin=http%3A%2F%2Fwww.editey.com' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. ...which obviously is misleading as the share button is not in a frame. Opening the give url in a new browser tab gives a hint to the real root-cause: Application '34534593617

Categories : Javascript

Accesing files from shared in google drive
To get a list of the files shared with you, you can use the drive.files.list request with the sharedWithMe filter.

Categories : Objective C

Reading text from Google Drive files
From Files.get() documentation. private static InputStream downloadFile(Drive service, File file) { if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) { try { HttpResponse resp = service.getRequestFactory().buildGetRequest(new GenericUrl(file.getDownloadUrl())) .execute(); return resp.getContent(); } catch (IOException e) { // An error occurred. e.printStackTrace(); return null; } } else { // The file doesn't have any content stored on Drive. return null; } } You can convert InputStream to String or File as you want.

Categories : Android

How to select files from google drive in android?
There is an api for this. I think this google's documentation should help https://developers.google.com/drive/android/queries. I'm not sure on how you want to go about it.

Categories : Android

Upload files from blobstore to Google Drive
There are several problems with your code. MediaSource receives either a file_path or a file_handle. If a file_path is provided it has to be the path of a readable file in the filesystem. Alternatively you can provide a file like object (an opened file) as the file_handle. See the documentation or the source. blobstore.create is a function that creates a filename that can be opened for writing only with the blobstore service and is in fact deprecated. If you already have the file in blobstore, you need to use BlobInfo.open instead. ms = gdata.MediaSource(file_handle=blobinfo.open(), content_type="text/plain"). Also, I hope that the pasted password is not a real one. Note as well that asking the user for her password is not a good practice and you should use OAuth instead. Note as we

Categories : Python

Listing files with same extension using google drive sdk
Google Drive determines file types based on their mimeType attribute, not their extension. Instead of looking at the file name, try something like: FileList temp = service.files().list().setQ("mimeType = 'image/jpeg'").execute();

Categories : Android

How to delete email field from Contacts via Google Apps Script
You may be running into a transient service issue, because there's nothing obviously wrong with your code. You could improve its efficiency and eliminate all the delete / add operations, though, and that might reduce the possibility of the error. Try this: /** * Find all contacts that have email addresses in the oldDomain, * and change them to be the same ID in the newDomain. * * @param {String} oldDomain E.g. 'oldExample.com' * @param {String} newDomain E.g. 'newExample.org' * * @returns {Number} Count of updated contacts. */ function migrateDomain(oldDomain, newDomain){ // Validate arguments if (arguments.length !== 2) throw new Error( 'Missing arguments.'); oldDomain = '@' + oldDomain; newDomain = '@' + newDomain; // retrieve all the user's contacts that

Categories : Google Apps Script

Extracting email address from Txt,PDf, Doc files in Google Drive
No it doesn't seem like that's trivially possible without a lot of code. What I would do personally is open up each file in google docs, search for @, and copy one at a time (how many emails do you have to find?). If you need to do this with python you will have to download all the files (easy enough with google drive). Then go through each file format and use the specific method on those. For text, just read in each file with with open("filename") as file: and search for emails line by line with regex. re.search. For pdf use PyPDF, link. For doc, first convert it to a file that python can open with catdoc, and then open it as text. If you need to automate all of this entirely you may want to look into either web automation packages for downloading, or building a google drive/docs ex

Categories : PHP

Google Drive SDK Push Notifications - watch changes on all files?
Long story short, no. Push Notification for now only supports watching on Files and Changes. As you might know, folders in Google Drive is File with special mimeType. That is, you can watch on a specific folder by making Files.Watch() request to a folder. However, it will only tell you changes in its direct children, not recursively, which is probably not what you wanted. The best approach you could take is to make copy of all file's metadata to your application and compare it when any changes happened. I know this is not very efficient, but for now, this is the only way you could achieve this goal. And if you ask me if the feature you want will be created, not likely. Push notifications is not only for Drive API. It is designed for all Google API to watch on any API resource and detect

Categories : Google App Engine

Search for files (with conditions) in the Google Drive SDK using Java
I found it. I think the Google Drive SDK documentation needs to be a little less ambiguous. Files.List request = service.files().list().setQ("mimeType = 'application/vnd.google-apps.folder'");

Categories : Java

How do I use Google Picker to access files using the "drive.file" scope?
In addition to setting the app ID, make sure the page you're serving the picker on is listed in your javascript origins in the APIs console. Both the app ID and the origin need to match for files to be authorized.

Categories : Javascript

Uploading files with Flask (running on App Engine) to Google Drive
Upload the form to blobstore with a callback into your frontend. If the file is very large you might need to go as far as a backend with resumable uploads done on chained backends (as backends could also go down in the middle of the upload for huge files)

Categories : Python

how to sync files from mysql hosting site to google drive
There's no direct way of synchronizing your local data with Drive. However, you can pseudo-sync with little load on your server by using Changes. Basically, you can get list of file changes since the time you specify. If I were you, I make a cron job of checking file changes from Drive and Files.get specific files that have changed.

Categories : Mysql

How to upload and access spreadsheet files from Google Drive in Dr.Edit sample code?
For Google Docs (Spreadsheet, Presentation, etc) file formats, you cannot get downloadUrl which is the way Dr.Edit accesses file. Instead, in same file metadata resource where you can get downloadUrl, you can get exportLinks, which exports spreadsheet to known file formats such as Microsoft Excel or csv. You can work with those known file format and upload it again to Google Spreadsheet by setting convert=true when uploading file.

Categories : IOS

keeping last 7 days zip files and deleting rest all files from a directory
Do you really need to sort and all? If you need to delete files which are more than 7 days old, get the lastModifieddate and substract it from current time. if the difference is more than 7*24*60*60 seconds then you can delete it. All you need is a for loop after the f.listFiles() line. Not actual code - use to get to the working code. long timeInEpoch = System.currentTimeMillis(); // slightly faster than new Date().getTimeInMillis(); File f = new File("/tmp"); if (f.isDirectory()) { final File[] files = f.listFiles(); for(int i =0; i < files.length ; i++ ) { if( timeInEpoch - f.lastModifiedDate() > 1000*60*60*24*7 ) files[i].delete(); } System.out.println(fileList); }

Categories : Java

Google Drive resumable upload has suddenly stopped working for Google Apps Marketplace App
I have experienced a similar problem. See POST method for resumable media link stopped working The solution we found was not related to the key and key secret. We just switched from an HTTP POST method to a PUT method.

Categories : Google App Engine

Through Google Apps Script get all user information on a spreadsheet of a google apps domain
Some of what you are looking for is best requested via the Admin SDK. You may want to also check out other Google Data APIs in more detail, you could put together some good reporting tools. Many of the APIs can be used in Google Apps Script by using the UrlFetch service. There's an OAuth flow built in that service that is quite nice for OAuth 1 flows, and it's not too bad to create a decent Google OAuth 2 flow with UrlFetch as well. Then you can make authenticated requests to those APIs and handle the responses accordingly with Apps Script.

Categories : Google Apps Script



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.