Batch file move to directory structure based on filename

I am creating a manuscript to relocate documents right into directory sites based upon the filename. Documents have yyyyddmm-xxxxxxx.jpg name layout. The wanted directory site framework remains in the layout 2013/01 Jan/31. I am incapable to get date to layout appropriately with a room in between month number and also month name. When I attempt to make use of +%Y/%m %b layout, I get this mistake message:

date: added operand `% b"'

I attempted double and also solitary quote marks, yet fruitless. Nonetheless, date +"%Y/%m %b/%d" functions penalty in sh:

2013/10/27 Oct

Also, exists a far better means to create the directory site name than making use of MOVEDIRSTR and also MOVEDIR variables (see manuscript)?

Below is my existing script:

FLIST=`ls "$IMGDIR" | grep -E '^.*\.jpg$'`

# If there are files to move
if [ -n "${FLIST}" ]; then
    # For each file
    while read -r line; do
        # Parse filename to YYYY/mm Mmm/Dd
        echo $line
        MOVEDIRSTR=`sed -r -e 's:([0-9]{4})([0-9]{2})([0-9]{2}).*:date -d \1-\2-\3 +%Y/%m_%b/%d:' <<< "$line"`

        # If a directory does not exist, create it
        [ -d "$ARCHIVEDIR/$MOVEDIR" ] || (mkdir -p "$ARCHIVEDIR/$MOVEDIR")

        # Move file into YYYY/mm Mmm directory
        # mv -f "$IMGDIR/$line" "$ARCHIVEDIR/$MOVEDIR"
    done <<< "$FLIST"
2022-07-25 20:41:54
Source Share
Answers: 0