bashrc function to create a folder every month and switch XDG_DESKTOP_DIR to it
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am actively using desktop, so files and folders rapidly accumulate on desktop.
I need a bashrc
way that it checks month on the first day then creates a directory with month name, finally sets it desktop
.
shell-script bashrc desktop-environment desktop xdg-user-dirs
add a comment |Â
up vote
0
down vote
favorite
I am actively using desktop, so files and folders rapidly accumulate on desktop.
I need a bashrc
way that it checks month on the first day then creates a directory with month name, finally sets it desktop
.
shell-script bashrc desktop-environment desktop xdg-user-dirs
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am actively using desktop, so files and folders rapidly accumulate on desktop.
I need a bashrc
way that it checks month on the first day then creates a directory with month name, finally sets it desktop
.
shell-script bashrc desktop-environment desktop xdg-user-dirs
I am actively using desktop, so files and folders rapidly accumulate on desktop.
I need a bashrc
way that it checks month on the first day then creates a directory with month name, finally sets it desktop
.
shell-script bashrc desktop-environment desktop xdg-user-dirs
edited Nov 28 '17 at 20:18
Jeff Schaller
32.1k849109
32.1k849109
asked Nov 28 '17 at 20:16
kenn
276516
276516
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
- you can set up a cronjob, that runs a script of your daily:
man crontab
- in the script you:
- create a folder for the last month on your desktop:
man mkdir
and How do I assign last month's date (year and month only - 2016-07) as a variable? - you run a
find
that finds all files that are older than one month. Here's an example of afind
that deletes (rm
) older files -
you'll need to adapt it tomv
older files into the created directory: Delete files older than X days +
- create a folder for the last month on your desktop:
add a comment |Â
up vote
1
down vote
First manually change the config by yourself for this month and run this for the next month.
change_desktop()
Desktop/$last_month
This will create the current month's folder in Desktop and then look for the last month in the config and change it to the current month.
I don't know how to run this piece automatically using the ~/.bashrc
, but you can setup a cron job for the user and let it run every month. Just add this code snippet to a file called change_desktop.sh
add the following code :
#!/bin/sh
change_desktop()
Desktop/$last_month
change_desktop
Then create a cron job for the current user like this :
0 0 12 * * sh /home/$USER/change_desktop.sh
If however you want to do this manually, you can add the first code snippet to the ~/.bashrc
and run change_desktop
in your terminal and it will do the job for you, as it is already a function in your ~/.bashrc
.
Thank you for the answer. Does it require to check if current month's folder exists?
â kenn
Nov 29 '17 at 9:37
add a comment |Â
up vote
1
down vote
I have managed to concoct my own script.
new_desktop="$HOME/Desktop/$(LC_ALL=tr_TR.utf8 date +'%B-%Y')"
if [ ! -d "$new_desktop" ]; then
mkdir "$new_desktop"
xdg-user-dirs-update --set DESKTOP "$new_desktop"
nautilus -q
fi
But I doubt about how reliable it is.
The script looks nice to me! I allowed myself to improve it a bit: indented it, corrected the line break, used a variable$new_desktop
instead of repeating the same expression over and over...
â Tomáà ¡ PospÃà ¡ek
Nov 29 '17 at 20:21
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
- you can set up a cronjob, that runs a script of your daily:
man crontab
- in the script you:
- create a folder for the last month on your desktop:
man mkdir
and How do I assign last month's date (year and month only - 2016-07) as a variable? - you run a
find
that finds all files that are older than one month. Here's an example of afind
that deletes (rm
) older files -
you'll need to adapt it tomv
older files into the created directory: Delete files older than X days +
- create a folder for the last month on your desktop:
add a comment |Â
up vote
1
down vote
- you can set up a cronjob, that runs a script of your daily:
man crontab
- in the script you:
- create a folder for the last month on your desktop:
man mkdir
and How do I assign last month's date (year and month only - 2016-07) as a variable? - you run a
find
that finds all files that are older than one month. Here's an example of afind
that deletes (rm
) older files -
you'll need to adapt it tomv
older files into the created directory: Delete files older than X days +
- create a folder for the last month on your desktop:
add a comment |Â
up vote
1
down vote
up vote
1
down vote
- you can set up a cronjob, that runs a script of your daily:
man crontab
- in the script you:
- create a folder for the last month on your desktop:
man mkdir
and How do I assign last month's date (year and month only - 2016-07) as a variable? - you run a
find
that finds all files that are older than one month. Here's an example of afind
that deletes (rm
) older files -
you'll need to adapt it tomv
older files into the created directory: Delete files older than X days +
- create a folder for the last month on your desktop:
- you can set up a cronjob, that runs a script of your daily:
man crontab
- in the script you:
- create a folder for the last month on your desktop:
man mkdir
and How do I assign last month's date (year and month only - 2016-07) as a variable? - you run a
find
that finds all files that are older than one month. Here's an example of afind
that deletes (rm
) older files -
you'll need to adapt it tomv
older files into the created directory: Delete files older than X days +
- create a folder for the last month on your desktop:
answered Nov 28 '17 at 20:46
Tomáà ¡ PospÃà ¡ek
542110
542110
add a comment |Â
add a comment |Â
up vote
1
down vote
First manually change the config by yourself for this month and run this for the next month.
change_desktop()
Desktop/$last_month
This will create the current month's folder in Desktop and then look for the last month in the config and change it to the current month.
I don't know how to run this piece automatically using the ~/.bashrc
, but you can setup a cron job for the user and let it run every month. Just add this code snippet to a file called change_desktop.sh
add the following code :
#!/bin/sh
change_desktop()
Desktop/$last_month
change_desktop
Then create a cron job for the current user like this :
0 0 12 * * sh /home/$USER/change_desktop.sh
If however you want to do this manually, you can add the first code snippet to the ~/.bashrc
and run change_desktop
in your terminal and it will do the job for you, as it is already a function in your ~/.bashrc
.
Thank you for the answer. Does it require to check if current month's folder exists?
â kenn
Nov 29 '17 at 9:37
add a comment |Â
up vote
1
down vote
First manually change the config by yourself for this month and run this for the next month.
change_desktop()
Desktop/$last_month
This will create the current month's folder in Desktop and then look for the last month in the config and change it to the current month.
I don't know how to run this piece automatically using the ~/.bashrc
, but you can setup a cron job for the user and let it run every month. Just add this code snippet to a file called change_desktop.sh
add the following code :
#!/bin/sh
change_desktop()
Desktop/$last_month
change_desktop
Then create a cron job for the current user like this :
0 0 12 * * sh /home/$USER/change_desktop.sh
If however you want to do this manually, you can add the first code snippet to the ~/.bashrc
and run change_desktop
in your terminal and it will do the job for you, as it is already a function in your ~/.bashrc
.
Thank you for the answer. Does it require to check if current month's folder exists?
â kenn
Nov 29 '17 at 9:37
add a comment |Â
up vote
1
down vote
up vote
1
down vote
First manually change the config by yourself for this month and run this for the next month.
change_desktop()
Desktop/$last_month
This will create the current month's folder in Desktop and then look for the last month in the config and change it to the current month.
I don't know how to run this piece automatically using the ~/.bashrc
, but you can setup a cron job for the user and let it run every month. Just add this code snippet to a file called change_desktop.sh
add the following code :
#!/bin/sh
change_desktop()
Desktop/$last_month
change_desktop
Then create a cron job for the current user like this :
0 0 12 * * sh /home/$USER/change_desktop.sh
If however you want to do this manually, you can add the first code snippet to the ~/.bashrc
and run change_desktop
in your terminal and it will do the job for you, as it is already a function in your ~/.bashrc
.
First manually change the config by yourself for this month and run this for the next month.
change_desktop()
Desktop/$last_month
This will create the current month's folder in Desktop and then look for the last month in the config and change it to the current month.
I don't know how to run this piece automatically using the ~/.bashrc
, but you can setup a cron job for the user and let it run every month. Just add this code snippet to a file called change_desktop.sh
add the following code :
#!/bin/sh
change_desktop()
Desktop/$last_month
change_desktop
Then create a cron job for the current user like this :
0 0 12 * * sh /home/$USER/change_desktop.sh
If however you want to do this manually, you can add the first code snippet to the ~/.bashrc
and run change_desktop
in your terminal and it will do the job for you, as it is already a function in your ~/.bashrc
.
edited Nov 28 '17 at 22:32
answered Nov 28 '17 at 20:56
Hunter.S.Thompson
4,53631334
4,53631334
Thank you for the answer. Does it require to check if current month's folder exists?
â kenn
Nov 29 '17 at 9:37
add a comment |Â
Thank you for the answer. Does it require to check if current month's folder exists?
â kenn
Nov 29 '17 at 9:37
Thank you for the answer. Does it require to check if current month's folder exists?
â kenn
Nov 29 '17 at 9:37
Thank you for the answer. Does it require to check if current month's folder exists?
â kenn
Nov 29 '17 at 9:37
add a comment |Â
up vote
1
down vote
I have managed to concoct my own script.
new_desktop="$HOME/Desktop/$(LC_ALL=tr_TR.utf8 date +'%B-%Y')"
if [ ! -d "$new_desktop" ]; then
mkdir "$new_desktop"
xdg-user-dirs-update --set DESKTOP "$new_desktop"
nautilus -q
fi
But I doubt about how reliable it is.
The script looks nice to me! I allowed myself to improve it a bit: indented it, corrected the line break, used a variable$new_desktop
instead of repeating the same expression over and over...
â Tomáà ¡ PospÃà ¡ek
Nov 29 '17 at 20:21
add a comment |Â
up vote
1
down vote
I have managed to concoct my own script.
new_desktop="$HOME/Desktop/$(LC_ALL=tr_TR.utf8 date +'%B-%Y')"
if [ ! -d "$new_desktop" ]; then
mkdir "$new_desktop"
xdg-user-dirs-update --set DESKTOP "$new_desktop"
nautilus -q
fi
But I doubt about how reliable it is.
The script looks nice to me! I allowed myself to improve it a bit: indented it, corrected the line break, used a variable$new_desktop
instead of repeating the same expression over and over...
â Tomáà ¡ PospÃà ¡ek
Nov 29 '17 at 20:21
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I have managed to concoct my own script.
new_desktop="$HOME/Desktop/$(LC_ALL=tr_TR.utf8 date +'%B-%Y')"
if [ ! -d "$new_desktop" ]; then
mkdir "$new_desktop"
xdg-user-dirs-update --set DESKTOP "$new_desktop"
nautilus -q
fi
But I doubt about how reliable it is.
I have managed to concoct my own script.
new_desktop="$HOME/Desktop/$(LC_ALL=tr_TR.utf8 date +'%B-%Y')"
if [ ! -d "$new_desktop" ]; then
mkdir "$new_desktop"
xdg-user-dirs-update --set DESKTOP "$new_desktop"
nautilus -q
fi
But I doubt about how reliable it is.
edited Nov 30 '17 at 3:14
Tomáà ¡ PospÃà ¡ek
542110
542110
answered Nov 29 '17 at 11:44
kenn
276516
276516
The script looks nice to me! I allowed myself to improve it a bit: indented it, corrected the line break, used a variable$new_desktop
instead of repeating the same expression over and over...
â Tomáà ¡ PospÃà ¡ek
Nov 29 '17 at 20:21
add a comment |Â
The script looks nice to me! I allowed myself to improve it a bit: indented it, corrected the line break, used a variable$new_desktop
instead of repeating the same expression over and over...
â Tomáà ¡ PospÃà ¡ek
Nov 29 '17 at 20:21
The script looks nice to me! I allowed myself to improve it a bit: indented it, corrected the line break, used a variable
$new_desktop
instead of repeating the same expression over and over...â Tomáà ¡ PospÃà ¡ek
Nov 29 '17 at 20:21
The script looks nice to me! I allowed myself to improve it a bit: indented it, corrected the line break, used a variable
$new_desktop
instead of repeating the same expression over and over...â Tomáà ¡ PospÃà ¡ek
Nov 29 '17 at 20:21
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f407579%2fbashrc-function-to-create-a-folder-every-month-and-switch-xdg-desktop-dir-to-it%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password