How to Add Timestamp with Folder Name and Automatically Upload It to Google Cloud
Know how to upload your files/folders to the cloud storage with minimal effort while automatically renaming them and adding a timestamp in the backup locations folder/file name, without making any changes in the local folders/files.

This article will cover: 1. How to create a bucket in GCP Console. 2. How to automatically rename a File/Folder and add a Timestamp to it while uploading it to GCP Cloud Storage keeping the original Filename same using a batch script. We can also automate the process using Time Scheduler in Windows. Why Google Cloud Storage? With Google Cloud Storage Integrate storage into your apps with a single unified API, optimize price/performance across four storage classes with Object Lifecycle Management, access data instantly from any storage class, and designed for secure and durable storage. How to create Cloud Bucket in GCP Console: 1. Open GCP Console and login with your credentials. Click the given link to go to GCP Console. https://console.cloud.google.com 2. Click on Navigation Menu in the top left corner. 3. Scroll Down and Click on Storage option. 4. Click on the Create Bucket option in the top and a new page will open in the console where you can customize your Bucket name, Class and Location. 5. Create a Bucket with your preferred name. Suppose here we are using the name “my-bucket-52” and Multi-Regional class so that the files that are uploaded in the bucket are stored in multiple locations and can be downloaded from multiple time from different regions. In the cost section, you can see the base cost of the project along with Class A operational charges and Class B operational charges. You can follow this link to check out what Class A and Class B operations include: https://cloud.google.com/storage/pricing 1. Click Create to create your bucket. 2. After Creating the bucket you will be redirected inside the bucket where you can view your files which you have already uploaded and you will also have the manual options to upload files, create or modify folders and also set permissions. 3. Now, your Bucket is created. How to use Timesceduler in windows to upload a specific folder periodically and rename it with the current timestamp using time scheduler: 1. First download and install Cloud SDK. 2. Create a Connection with your Cloud Bucket. 3. Now suppose I have created a folder inside C: Drive named New Folder containing a file Test.txt. 4. Now we have to create a another text file and write the following syntax inside the text file. The “Foldername” will be replaced by your folders name and the “filename” will be replaced by your file name if your are trying to upload your file with the timestamp. The “my-bucket-52” name will be replaced with you bucket name which is present in the Google Cloud Console. If you want to upload a specific File with Timestamp: gsutil cp C:\”Foldername”\”filename” gs://”my-bucket-52”%time:~0,2%-%time:~3,2%-%time:~6,2%_%date:~-10,2%-%date:~-7,2%-%date:~-4,4%.txt If you want to upload a specific Folders with Timestamp: gsutil -m cp -r C:\Foldername\* gs://”my-bucket-52”_%time:~0,2%-%time:~3,2%-%time:~6,2%_%date:~-10,2%-%date:~-7,2%-%date:~-4,4% 1. As we will upload the whole folder containing the Test.txt file we have created in the C: drive we will write our syntax as: 2. Now, we will save the file as folder.bat in the C:\ directory. 3. Now we will use Time scheduler which is preinstalled in Windows. 4. Click start and type time scheduler to open the application and the following window will appear: 5. Click on Create task to Schedule a new task and the following window will appear. 6. Name your task as per required. For example, the purpose we have named it here as newtask. 7. Now click on the Action tab and click new. Here you need to select the .bat file you have created. I have used the folder.bat file which was saved in the C:\ Directory. 8. Press ok to confirm, and then goto the trigger tab, and click the new to configure you the automatic time the file/folder needs to be uploaded. A window will appear like the following, put your own values in the new window to automate the time to upload. 9. Now click ok to confirm. Your task will be added to the task scheduler. 10. Now the process is complete and you will see that your folder will automatically get uploaded in the Google Cloud Bucket at the given time as scheduled in the Time Scheduler with the Timestamp. Note that the existing files in the Google Cloud Bucket won’t be replaced and the folder/file in your local drive will retain its original name.